varun_ramesh created OLINGO-1567:
------------------------------------

             Summary: Expected item not found exception while parsing batch 
response 
                 Key: OLINGO-1567
                 URL: https://issues.apache.org/jira/browse/OLINGO-1567
             Project: Olingo
          Issue Type: Bug
          Components: odata4-client
    Affects Versions: (Java) V4 4.8.0
         Environment: Not Applicable
            Reporter: varun_ramesh
         Attachments: sample_request.txt, sample_response.txt

While parsing batch changeset response, any of the changeset may fail (can have 
response code > 300). As per spec, a batch request and response must be 
structurally identical with an exception.
 # When a request within a change set fails, the change set response is not 
represented using the multipart/mixed media type. Instead, a single response, 
using the application/http media type, is returned that applies to all requests 
in the change set and MUST be a valid OData error response.

There is an issue in an iterator of the class ODataChangesetResponseItem.java 
where hasNext() returns true but when next() is called "IllegalStateException : 
Expected item not found" exception is thrown. 

 

When the condition as mentioned in point 1 occurs, the iterators' hasNext() 
gives us true indicating there is a next element whereas fetching the element 
using next() gives an exception. This will happen when there are multiple 
changeset parts but the remote service gives failure response for only one 
changeset part. I have attached a sample request and response too.

 

On the other hand even if we set continueOnError to false, when the service 
gives all the failure response, ODataChangesetResponseItem's iterator will 
parse only the first response. Ideally there seems to be a flaw in the iterator 
design. I have a unit test in this project 
[https://github.com/varunrr/olingo-response] reproducing the scenario where the 
backend service is  https://services.odata.org/TripPinRESTierService.

 



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to