You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Chris Lott <ma...@invest-faq.com> on 2009/11/18 13:52:28 UTC
Re: Warning: SimpleHttpConnectionManager being used incorrectly
I am writing a follow-on to the thread started by Christoph Jaehnigen on
Wed, 23 Sep 2009 15:05:35 GMT about warnings emitted by the Apache
HttpClient SimpleHttpConnectionManager. I am using
commons-httpclient-3.1-rc1. This message appears:
>org.apache.commons.httpclient.SimpleHttpConnectionManager
>getConnectionWithTimeout
>WARNING: SimpleHttpConnectionManager being used incorrectly. Be sure
>that HttpMethod.releaseConnection() is always called and that only one
>thread and/or method is using this connection manager at a time.
Below I have attached a simplified class that reproduces the problem.
You can see that the code is single threaded and always, always calls
method.releaseConnection(). Yet the warning still appears. Frustrating!
After some goofing I think I may have stumbled upon a workaround, and
would like to get your input. Basically I added a call to method.abort()
in the exception clause triggered by timeout. If that is done, I get no
warning from SimpleConnectionManager. Is this the right thing to do, or
is there some deeper issue to be solved?
Please reply, thanks.
chris...
p.s. I see now that HC 4.0 is available, I better try that, huh?