You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Tyrone (Jira)" <ji...@apache.org> on 2019/09/23 17:46: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=16936069#comment-16936069 ]
Tyrone commented on HTTPCORE-561:
---------------------------------
Hi,
This ticket helped me resolve a problem with a "Socket is closed" exception. I encountered virtually the same symptoms and tracked it down to those same exact lines in fillInputBuffer. However, in my case, It was not the 3 second auto close that was triggering. We were using the aws s3 sdk and not specifying the correct region. The target s3 was closing the socket.
Thanks
> 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
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org