[
https://issues.apache.org/jira/browse/OLINGO-504?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Christian Amend resolved OLINGO-504.
------------------------------------
Resolution: Fixed
Assignee: Christian Amend
Fixed through contribution with
commit:https://git-wip-us.apache.org/repos/asf?p=olingo-odata2.git;a=commit;h=9f39956a3e0b239069ea65b4444f83032e73dfb4
Thank you for the contribution!
> Incorrect reading of child annotation elements
> ----------------------------------------------
>
> Key: OLINGO-504
> URL: https://issues.apache.org/jira/browse/OLINGO-504
> Project: Olingo
> Issue Type: Bug
> Components: odata2-core
> Affects Versions: V2 2.0.1
> Reporter: Vitali Yarmolik
> Assignee: Christian Amend
> Attachments: Olingo504.diff
>
>
> We have the following scenario: There is an XML file which stores EDM
> metadata. The file is parsed by
> {{org.apache.olingo.odata2.core.ep.consumer.XmlMetadataConsumer}} class in
> order to get an object representation of the metadata. Such an object
> representation is handled after that in an application-specific way.
> In our case, the EDM metadata also contains custom annotation elements which
> are specified for the EDM schema and represented in the following way:
> {code:xml}
> <CustomAnnotations xmlns="http://company.com/odata">
> <annotation1>value1</annotation1>
> <annotation2>value2</annotation2>
> </CustomAnnotations>
> {code}
> So, basically we have a schema-level CustomAnnotations annotation element
> which has two child annotation elements.
> After parsing the XML file with the metadata, we get an instance of
> {{org.apache.olingo.odata2.api.edm.provider.DataServices}} from which we want
> to get the custom annotation element along with its child annotation
> elements. The problem is that the returned instance of
> {{org.apache.olingo.odata2.api.edm.provider.AnnotationElement}}, which
> corresponds to CustomAnnotations element, returns 'null' when its child
> annotation elements are requested via {{getChildElements()}} method.
> After debugging I found that the problem is in
> {{readAnnotationElement(XMLStreamReader)}} method of {{XmlMetadataConsumer}}.
> The problem occurs when there is a white space after the open XML tag for the
> parent Annotation Element. In our case, we had white space after
> {{<CustomAnnotations>}} XML tag. In such a case, {{readAnnotationElement()}}
> method reads the characters using the following code:
> {code}
> String elementText = "";
> do {
> elementText = elementText + reader.getText();
> reader.next();
> } while (reader.isCharacters());
> aElement.setText(elementText);
> {code}
> The problem is that {{reader.next()}} method is called twice: during reading
> the characters and in the outer 'while' loop. As a result, open XML tag for
> the child annotation element is skipped.
> Removing of additional spaces from the EDM XML fixes the issue, but, in my
> opinion, the implementation of {{XmlMetadataConsumer}} should be improved.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)