Duplicate :
|
|
Duplicate :
|
|
Relates :
|
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.
|