hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ortwin Gl├╝ck <...@odi.ch>
Subject Re: Question on HTTPClient-675
Date Mon, 15 Jun 2009 17:22:41 GMT

> We are still using HttpClient 3.0.1

Consider upgrading.

> I saw there is a bug HTTPClient-675 that was fixed by Roland Weber in
> version 3.1.  It talks about thread-starving in the
> MultiThreadedHttpConnectionManager and made me wonder if we were seeing
> something similar occurring.  

As you are not using the MTCM, that issue does not affect you.

> I emailed Roland

Generally you do not email indidivual developers. They might not even bother

>         HttpClient client = new HttpClient();
>         PostMethod post = new PostMethod(inUrl);
>         post.setRequestEntity(new StringRequestEntity(inPayload, null,
> null));
>         int statusCode = client.executeMethod(post);
>         log.debug(new StringBuilder("inUrl=").append(inUrl).append(",
> inPayload=")
>                     .append(inPayload).append(", statusCode=")
>                     .append(statusCode).toString());
>         String payload = readPayload(post);
>         return payload;
> The readPayload method just uses post.getResponseBodyAsStream and a
> BufferedReader to read the response.
> The BufferedReader is then closed in a finally block.

This code does not call post.releaseConnection() at all! It will leak
connections. It could be that you are running out of file descriptors. The call
should be put into a finally block. See the example code on the website.

> Sincerely,
> David Hamilton

Hope that helps,


[web]  http://www.odi.ch/
[blog] http://www.odi.ch/weblog/
[pgp]  key 0x81CF3416
       finger print F2B1 B21F F056 D53E 5D79 A5AF 02BE 70F5 81CF 3416

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

View raw message