Uploaded image for project: 'HttpComponents HttpClient'
  1. HttpComponents HttpClient
  2. HTTPCLIENT-1274

NullPointerException on 304 Not Modified response

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 4.2.3
    • HttpCache
    • None

    Description

      When sending a conditional request (If-None-Match for example) and the backend responds with a 304 Not Modified, the response contains an HttpEntity but you get a NullPointerException whenever to try to call one of the methods :

      • org.apache.http.HttpEntity.getContent()
      • org.apache.http.HttpEntity.writeTo(OutputStream)

      I would expect getEntity() to return null if there is no entity in the response.

      As a workaround I can test on the contentLength before calling these methods and call EntityUtils.consume(entity) to get sure that the connection is released but this makes things more complicated.

      Attachments

        1. TestCachingExec.patch.txt
          2 kB
          Francois-Xavier Bonnet

        Activity

          People

            Unassigned Unassigned
            fx.bonnet Francois-Xavier Bonnet
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: