hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 35944] - Connection is not released back to the pool if a runtime exception is thrown in HttpMethod#releaseConnection method
Date Fri, 05 Aug 2005 14:16:46 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=35944>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=35944





------- Additional Comments From plynch@apache.org  2005-08-05 16:16 -------
I just read this thread with interest as a simple junit test on my end
reproduced this quite easily, although without all the waiting around - by using
a proxy server instead.

Here is code that will reproduce this for me every time.

HttpClient httpClient =
new HttpClient(new MultiThreadedHttpConnectionManager());
final HttpConnectionManagerParams params =
    httpClient.getHttpConnectionManager().getParams();
params.setMaxTotalConnections(20);
params.setDefaultMaxConnectionsPerHost(20);
httpClient.getParams().setCookiePolicy(CookiePolicy.IGNORE_COOKIES);

// *this next line helps trigger IllegalStateException*
// without a proxy , we get an UnknownHostException instead
// the proxy server is running normally
httpClient.getHostConfiguration().setProxy("127.0.0.1", 8222);
// use a non-reachale url
final PostMethod post = new PostMethod("http://foo/bar/baz");
final NameValuePair[] data ={new NameValuePair("name", "value")};
post.setRequestBody(data);
try
{
    //next line throws non-doc'd IllegalStateException
    httpClient.executeMethod(post);
    // print response to stdout
    System.out.println(post.getResponseBodyAsStream());
}
finally
{
    post.releaseConnection();
}

Trace this creates from the call to executeMethod()
---------------------------------------------------

java.lang.IllegalStateException: Connection is not open
        at
org.apache.commons.httpclient.HttpConnection.assertOpen(HttpConnection.java:1269)
        at
org.apache.commons.httpclient.HttpConnection.write(HttpConnection.java:968)
        at
org.apache.commons.httpclient.HttpConnection.write(HttpConnection.java:937)
        at
org.apache.commons.httpclient.HttpConnection.print(HttpConnection.java:1027)
        at
org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.print(MultiThreadedHttpConnectionManager.java:1622)
        at
org.apache.commons.httpclient.HttpMethodBase.writeRequestHeaders(HttpMethodBase.java:2046)
        at
org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:1919)
        at
org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:993)
        at
org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:393)
        at
org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:168)
        at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:396)
        at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:324)



-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


Mime
View raw message