[
https://issues.apache.org/jira/browse/OLINGO-534?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Christian Amend updated OLINGO-534:
-----------------------------------
Issue Type: Sub-task (was: Bug)
Parent: OLINGO-530
> Problem when deserializing an entity with JSON
> ----------------------------------------------
>
> Key: OLINGO-534
> URL: https://issues.apache.org/jira/browse/OLINGO-534
> Project: Olingo
> Issue Type: Sub-task
> Components: odata4-server
> Affects Versions: (Java) V4 4.0.0-beta-02
> Reporter: Thierry Templier
> Assignee: Christian Amend
>
> Hello,
> I try to deserialize an entity sent by an OData client and I have the
> following exception:
> Tree should be empty but still has content left.
> at
> org.apache.olingo.server.core.deserializer.json.ODataJsonDeserializer.consumeEntityNode(ODataJsonDeserializer.java:262)
> at
> org.apache.olingo.server.core.deserializer.json.ODataJsonDeserializer.entity(ODataJsonDeserializer.java:156)
> at
> org.apache.olingo.data.providers.ODataProvidersProcessor.updateEntity(ODataProvidersProcessor.java:250)
> at
> org.apache.olingo.server.core.ODataHandler.handleEntityDispatching(ODataHandler.java:636)
> at
> org.apache.olingo.server.core.ODataHandler.handleEntityDispatching(ODataHandler.java:585)
> at
> org.apache.olingo.server.core.ODataHandler.handleResourceDispatching(ODataHandler.java:253)
> at
> org.apache.olingo.server.core.ODataHandler.processInternal(ODataHandler.java:194)
> at
> org.apache.olingo.server.core.ODataHandler.process(ODataHandler.java:111)
> After having investigated a bit the problem, it appears that the metadata
> type fields (for example fields like this: [email protected]) aren't handled
> and Jackson parsing tree isn't empty at the very end of the processing.
> A quick fix consists in adding the following lines (see
> field.getKey().endsWith(Constants.JSON_TYPE)):
> final List<String> toRemove = new ArrayList<String>();
> Iterator<Entry<String, JsonNode>> fieldsIterator = tree.fields();
> // TODO: Add custom annotation support
> while (fieldsIterator.hasNext()) {
> Map.Entry<String, JsonNode> field = (Map.Entry<String, JsonNode>)
> fieldsIterator.next();
> if (field.getKey().endsWith(Constants.JSON_NAVIGATION_LINK)) {
> (...)
> } else if (field.getKey().endsWith(Constants.JSON_ASSOCIATION_LINK)) {
> (...)
> } else if (field.getKey().endsWith(Constants.JSON_TYPE)) {
> toRemove.add(field.getKey());
> }
> After adding these two lines, things work well!
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)