[OLINGO-1232]Metadata parsing goes into an infinite loop when there is a collection of Records inside Annotation groups

This commit is contained in:
ramya vasanth 2018-02-08 15:03:15 +05:30
parent d55ed59d0d
commit 213a8c0683
3 changed files with 1107 additions and 1 deletions

View File

@ -46,8 +46,10 @@ class ClientCsdlRecord extends CsdlRecord implements Serializable {
if ("Type".equals(jp.getCurrentName())) {
record.setType(jp.nextTextValue());
} else if ("Annotation".equals(jp.getCurrentName())) {
jp.nextToken();
record.getAnnotations().add(jp.readValueAs(ClientCsdlAnnotation.class));
} else {
} else if ("PropertyValue".equals(jp.getCurrentName())) {
jp.nextToken();
record.getPropertyValues().add(jp.readValueAs(ClientCsdlPropertyValue.class));
}
}

View File

@ -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.CsdlCollection;
import org.apache.olingo.commons.api.edm.provider.annotation.CsdlConstantExpression;
import org.apache.olingo.commons.api.edm.provider.annotation.CsdlExpression;
//CHECKSTYLE:OFF
import org.apache.olingo.commons.api.edm.provider.annotation.CsdlLogicalOrComparisonExpression.LogicalOrComparisonExpressionType;
//CHECKSTYLE:ON
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.format.ContentType;
import org.apache.olingo.commons.core.edm.primitivetype.EdmDecimal;
@ -481,4 +483,20 @@ public class MetadataTest extends AbstractTest {
assertNull(providerLicensePractices.getRelatedBindingTarget("Provider"));
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());
}
}