[OLINGO-1232]Metadata parsing goes into an infinite loop when there is a collection of Records inside Annotation groups
This commit is contained in:
parent
d55ed59d0d
commit
213a8c0683
|
@ -46,8 +46,10 @@ class ClientCsdlRecord extends CsdlRecord implements Serializable {
|
||||||
if ("Type".equals(jp.getCurrentName())) {
|
if ("Type".equals(jp.getCurrentName())) {
|
||||||
record.setType(jp.nextTextValue());
|
record.setType(jp.nextTextValue());
|
||||||
} else if ("Annotation".equals(jp.getCurrentName())) {
|
} else if ("Annotation".equals(jp.getCurrentName())) {
|
||||||
|
jp.nextToken();
|
||||||
record.getAnnotations().add(jp.readValueAs(ClientCsdlAnnotation.class));
|
record.getAnnotations().add(jp.readValueAs(ClientCsdlAnnotation.class));
|
||||||
} else {
|
} else if ("PropertyValue".equals(jp.getCurrentName())) {
|
||||||
|
jp.nextToken();
|
||||||
record.getPropertyValues().add(jp.readValueAs(ClientCsdlPropertyValue.class));
|
record.getPropertyValues().add(jp.readValueAs(ClientCsdlPropertyValue.class));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,10 +63,12 @@ import org.apache.olingo.commons.api.edm.provider.CsdlTerm;
|
||||||
import org.apache.olingo.commons.api.edm.provider.annotation.CsdlApply;
|
import org.apache.olingo.commons.api.edm.provider.annotation.CsdlApply;
|
||||||
import org.apache.olingo.commons.api.edm.provider.annotation.CsdlCollection;
|
import org.apache.olingo.commons.api.edm.provider.annotation.CsdlCollection;
|
||||||
import org.apache.olingo.commons.api.edm.provider.annotation.CsdlConstantExpression;
|
import org.apache.olingo.commons.api.edm.provider.annotation.CsdlConstantExpression;
|
||||||
|
import org.apache.olingo.commons.api.edm.provider.annotation.CsdlExpression;
|
||||||
//CHECKSTYLE:OFF
|
//CHECKSTYLE:OFF
|
||||||
import org.apache.olingo.commons.api.edm.provider.annotation.CsdlLogicalOrComparisonExpression.LogicalOrComparisonExpressionType;
|
import org.apache.olingo.commons.api.edm.provider.annotation.CsdlLogicalOrComparisonExpression.LogicalOrComparisonExpressionType;
|
||||||
//CHECKSTYLE:ON
|
//CHECKSTYLE:ON
|
||||||
import org.apache.olingo.commons.api.edm.provider.annotation.CsdlPath;
|
import org.apache.olingo.commons.api.edm.provider.annotation.CsdlPath;
|
||||||
|
import org.apache.olingo.commons.api.edm.provider.annotation.CsdlRecord;
|
||||||
import org.apache.olingo.commons.api.edm.provider.annotation.CsdlUrlRef;
|
import org.apache.olingo.commons.api.edm.provider.annotation.CsdlUrlRef;
|
||||||
import org.apache.olingo.commons.api.format.ContentType;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.core.edm.primitivetype.EdmDecimal;
|
import org.apache.olingo.commons.core.edm.primitivetype.EdmDecimal;
|
||||||
|
@ -481,4 +483,20 @@ public class MetadataTest extends AbstractTest {
|
||||||
assertNull(providerLicensePractices.getRelatedBindingTarget("Provider"));
|
assertNull(providerLicensePractices.getRelatedBindingTarget("Provider"));
|
||||||
assertNull(providerLicenses.getRelatedBindingTarget("ProviderLicense"));
|
assertNull(providerLicenses.getRelatedBindingTarget("ProviderLicense"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void issueOLINGO1232() {
|
||||||
|
XMLMetadata xmlMetadata = client.getDeserializer(ContentType.APPLICATION_XML).
|
||||||
|
toMetadata(getClass().getResourceAsStream("caps.products.CatalogService_default.xml"));
|
||||||
|
assertNotNull(xmlMetadata);
|
||||||
|
assertEquals(94, xmlMetadata.getSchema(0).getAnnotationGroups().size());
|
||||||
|
List<CsdlExpression> expressions = xmlMetadata.getSchema(0).getAnnotationGroups().get(0).
|
||||||
|
getAnnotation("UI.LineItem").getExpression().asDynamic().asCollection().getItems();
|
||||||
|
assertEquals(6, expressions.size());
|
||||||
|
CsdlRecord record = (CsdlRecord) expressions.get(0);
|
||||||
|
assertEquals("UI.DataField", record.getType());
|
||||||
|
assertEquals(1, record.getAnnotations().size());
|
||||||
|
assertEquals("Value", record.getPropertyValues().get(0).getProperty());
|
||||||
|
assertEquals("image", record.getPropertyValues().get(0).getValue().asDynamic().asPath().getValue());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue