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

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

    [ https://issues.apache.org/jira/browse/HTTPCORE-561?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16666924#comment-16666924 ] 

Oleg Kalnichevski commented on HTTPCORE-561:
--------------------------------------------

{quote}Socket will be closed, in case of socket timeout exception{quote}

[~kyotov] Are sure about that? That would make the behavior of {{SocketTimeoutException}} inconsistent with that of plain sockets. Can you post the exception stack trace or better yet provide a reproducer?

Oleg

> 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
>            Priority: Major
>
> 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