hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: PoolingHttpClientConnectionManager and CloseableHttpResponse
Date Wed, 17 Sep 2014 08:08:41 GMT
On Tue, 2014-09-16 at 15:49 -0400, Todd W Lainhart wrote:
> > 
> > The connection manager has no way of knowing if a connection is still 
> > being used. No matter what it needs to be notified that the connection 
> > can be re-claimed (and either kept alive for further re-use or 
> > discarded). The #release method looks like a natural way of doing that.
> > 
> > Oleg
> > 
> Thanks - I'm still trying to grok, at a lower-level, the relationship 
> between the connection, the manager, and the pool.  I've got past the 
> connection pool shutdown problem (my code).  I'm now seeing ISE raised on 
> an unexpectedly closed HttpConnection (stack trace below).  I'm not 
> getting this one, as the RequestExecutor is successfully sending the 
> request, but it's erring out on the closed connection.
> Assuming that the connection is not shared across threads, and not being 
> closed by another thread, what would be a cause of the unexpected 
> connection close between the request and response?

HttpUriRequest#abort method shuts down the underlying connection. Any
further interaction with the same connection is likely to result in

> Thanks for your help.  My suspicion is that there is still someone holding 
> onto a connection, while in parallel, the connection manager from which 
> that connection was provisioned is shutdown. I'm wondering if there might 
> be another scenario.

This can happen if the request is aborted while still being executed.
However, the #abort method usually needs to be called from another


> Caused by: java.lang.IllegalStateException: Connection is not open
>         at org.apache.http.util.Asserts.check(Asserts.java:34)
>         at 
> org.apache.http.impl.BHttpConnectionBase.ensureOpen(BHttpConnectionBase.java:128)
>         at 
> org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseEntity(DefaultBHttpClientConnection.java:172)
>         at 
> org.apache.http.impl.conn.CPoolProxy.receiveResponseEntity(CPoolProxy.java:157)
>         at 
> org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:273)
>         at 
> org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:123)
>         at 
> org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:254)
>         at 
> org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:195)
>         at 
> org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:86)
>         at 
> org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:108)
>         at 
> org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)

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

View raw message