You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Christian Yotov (JIRA)" <ji...@apache.org> on 2018/10/29 08:52:00 UTC

[jira] [Created] (HTTPCORE-561) Exception overlap, when SocketFactory is created with autoclosable equals to true

Christian Yotov created HTTPCORE-561:
----------------------------------------

             Summary: Exception overlap, when SocketFactory is created with autoclosable equals to true
                 Key: HTTPCORE-561
                 URL: https://issues.apache.org/jira/browse/HTTPCORE-561
             Project: HttpComponents HttpCore
          Issue Type: Bug
          Components: HttpCore
            Reporter: Christian Yotov


When http is used over SSL, there is possibility exception to be overlapped. In class `DefaultBHttpClientConnection` in method `isResponseAvailable`, you're expecting `SocketTimeoutException`. If we look in `BhttpConnectionBase`, `fillInputBuffer` method, which is being called by `isResponseAvailable`, you set socket timeout before you start reading from socket and after that. In case socket factory has been created with property autoclosable equals to `true`. Socket will be closed, in case of socket timeout exception. This will cause second exception on second timeout set.

 
{code:java}
private int fillInputBuffer(final int timeout) throws IOException { 
    final Socket socket = this.socketHolder.get(); 
    final int oldtimeout = socket.getSoTimeout(); 
    try {
        // first you set socket timeout before reading
        socket.setSoTimeout(timeout); 
        // reading from socket, in case socket has timeout and socket factory         // is created with autoclosable equals to true, socket will be closed
        return this.inbuffer.fillBuffer(); 
    } finally { 
        // This operation will fail, in case socket has been timeout and //socket factory is created with autoclosable
        socket.setSoTimeout(oldtimeout);
    }
}
{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org