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

ClientResponse.getEntity() and ClientResponse.bufferEntity() do not completely follow the spec

    XMLWordPrintable

Details

    Description

      ClientReponse.getEntity():

      According to the Response.getEntity() javadoc this method MUST : "throw an IllegalStateException if the entity was previously fully consumed as an InputStream input stream". That what we started to achieve with asoldano in jira https://issues.jboss.org/browse/RESTEASY-1700, but i figured out that we forgot one case.

      Following case will fail for example:

      InputStream inputStream=response.readEntity(InputStream.class);
      //Fully consumed the original response stream
      while (inputStream.read() != -1)
      {
      }
      //Following line Must throw an IllegalStateException but it will not
      response.getEntity();
      

      ClientReponse.bufferEntity():

      According to the Response.bufferEntity() javadoc this method MUST : "return false in case the response entity instance is not backed by an unconsumed input stream" since it will prevent reading all the bytes of the original entity input stream given that the stream is already fully or partially consumed.
      Current implementation of ClientResponse does not follow those lines and following case fail for example:

      InputStream inputStream=(InputStream) response.getEntity();
      while (inputStream.read() != -1)
      {
      }
      //Following line Must return false but it will not
      response.bufferEntity()
      

      Attachments

        Issue Links

          Activity

            People

              rsigal@redhat.com Ronald Sigal
              nicones Nicolas NESMON
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: