Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-5795

Reading the entity from a Response with 202 - Accepted causes NullPointerException

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.7.11
    • Fix Version/s: 2.7.13, 3.0.2, 3.1
    • Component/s: JAX-RS
    • Labels:
      None
    • Environment:

      Apache CXF 2.7.11

    • Estimated Complexity:
      Unknown

      Description

      The entity of a Response with HTTP status code 202 - Accepted is null. This causes a NullPointerException when calling response.readEntity(). Furthermore, this bug seems to only occur when using the JAXRSClientFactory, and it was introduced in CXF 2.7.11.

      The stacktrace is of the NullPointerException:
      java.lang.NullPointerException
      at org.apache.cxf.jaxrs.impl.ResponseImpl.doReadEntity(ResponseImpl.java:345)
      at org.apache.cxf.jaxrs.impl.ResponseImpl.readEntity(ResponseImpl.java:286)
      at org.apache.cxf.jaxrs.impl.ResponseImpl.readEntity(ResponseImpl.java:276)

      To recreate the bug do the following:
      Create a REST service that returns a 202 - Accepted with a non-null entity. In our case, the service was for HTTP POST.
      Create a unit test that tests the service by creating a client with the JAXRSClientFactory and then reads the entity from the response.

      Both return Response.accepted(entity).build(); and return Response.status(Response.Status.ACCEPTED).entity(entity).build(); causes the bug.

        Attachments

        1. cxf-demo.zip
          7 kB
          Mathieu Durand

          Activity

            People

            • Assignee:
              sergey_beryozkin Sergey Beryozkin
              Reporter:
              danielpd Daniel Peder Dahlsveen
            • Votes:
              3 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: