Uploaded image for project: 'Olingo'
  1. Olingo
  2. OLINGO-1567

Expected item not found exception while parsing batch response

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • (Java) V4 4.8.0
    • None
    • odata4-client
    • None
    • Not Applicable

    Description

      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.

      1. 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 attached reproducing the scenario where the backend service is  https://services.odata.org/TripPinRESTierService.

       

      Attachments

        1. BatchResponseTest.java
          3 kB
          varun_ramesh
        2. sample_request.txt
          1 kB
          varun_ramesh
        3. sample_response.txt
          0.5 kB
          varun_ramesh

        Activity

          People

            Unassigned Unassigned
            varun_ramesh varun_ramesh
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: