Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-2462

Response.hasEntity throws exception if the response is closed

    XMLWordPrintable

Details

    • Bug
    • Resolution: Not a Bug
    • Major
    • None
    • 4.3.1.Final
    • jaxrs
    • None
    • Hide
      1. Use a proxy client to interact with a REST API which returns a 304 response.
      2. Call
        WebApplicationException.getResponse().hasEntity()
        

      Expected results: false is returned
      Actual results:

      Caused by: java.lang.IllegalStateException: RESTEASY003765: Response is closed.
      	at org.jboss.resteasy.specimpl.AbstractBuiltResponse.abortIfClosed(AbstractBuiltResponse.java:308)
      	at org.jboss.resteasy.client.jaxrs.internal.ClientResponse.abortIfClosed(ClientResponse.java:305)
      	at org.jboss.resteasy.client.jaxrs.internal.ClientResponse.hasEntity(ClientResponse.java:123)
      
      Show
      Use a proxy client to interact with a REST API which returns a 304 response. Call WebApplicationException.getResponse().hasEntity() Expected results: false is returned Actual results: Caused by: java.lang.IllegalStateException: RESTEASY003765: Response is closed. at org.jboss.resteasy.specimpl.AbstractBuiltResponse.abortIfClosed(AbstractBuiltResponse.java:308) at org.jboss.resteasy.client.jaxrs.internal.ClientResponse.abortIfClosed(ClientResponse.java:305) at org.jboss.resteasy.client.jaxrs.internal.ClientResponse.hasEntity(ClientResponse.java:123)

    Description

      When using the proxy client, generic code which handles WebApplicationException may fail if it calls hasEntity() on a response which for example is a 3xx response.

      It seems acceptable, that in this case (the response is closed) hasEntity could simply return false when closed, rather than throw an IllegalStateException.

      Attachments

        Activity

          People

            Unassigned Unassigned
            chcooper Christopher Cooper (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: