Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8009650

HttpClient available() check throws SocketException when connection has been closed

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 6u38, 7u40, 8
    • Fix Version/s: 8
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Introduced In Version:
    • Resolved In Build:
      b84
    • Verification:
      Verified

      Backports

        Description

        The HttpClient.available() method is used to check that a cached connection is still open. In order to do this we temporarily set the socket timeout to 1ms and then attempt to read. If we hit the socket timeout we know that the socket was open. If read returns -1 we know it is closed.

        Unfortunately the fact that the get/setSoTimeout()'s can themselves throw a SocketException was overlooked.

        The solution to this problem is to wrap the entire try/catch/finally block (we call setSoTimeout in the finally) in a try/catch (SocketException) which will catch the potential SocketException from the try and finally blocks.

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  robm Robert Mckenna
                  Reporter:
                  robm Robert Mckenna
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  5 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: