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

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 8
    • 6u38, 7u40, 8
    • core-libs
    • b84
    • Verified

        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.

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

                Created:
                Updated:
                Resolved: