Return-Path: Delivered-To: apmail-hc-dev-archive@www.apache.org Received: (qmail 85165 invoked from network); 15 Jun 2009 21:07:50 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 15 Jun 2009 21:07:50 -0000 Received: (qmail 31052 invoked by uid 500); 15 Jun 2009 21:08:02 -0000 Delivered-To: apmail-hc-dev-archive@hc.apache.org Received: (qmail 30999 invoked by uid 500); 15 Jun 2009 21:08:02 -0000 Mailing-List: contact dev-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list dev@hc.apache.org Received: (qmail 30989 invoked by uid 99); 15 Jun 2009 21:08:01 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 15 Jun 2009 21:08:01 +0000 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [92.42.190.144] (HELO ok2cons2.nine.ch) (92.42.190.144) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 15 Jun 2009 21:07:51 +0000 Received: from [192.168.1.101] (84-75-100-4.dclient.hispeed.ch [84.75.100.4]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ok2cons2.nine.ch (Postfix) with ESMTPSA id 026C34BA12E for ; Mon, 15 Jun 2009 23:07:30 +0200 (CEST) Message-ID: <4A36B801.90305@apache.org> Date: Mon, 15 Jun 2009 23:07:13 +0200 From: Oleg Kalnichevski User-Agent: Thunderbird 2.0.0.21 (Windows/20090302) MIME-Version: 1.0 To: HttpComponents Project Subject: Re: Question on HTTPClient-675 References: <4A368361.9090405@odi.ch> In-Reply-To: <4A368361.9090405@odi.ch> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org Ortwin Gl�ck wrote: > David, > >> 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 > responding. > >> 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. > David, Another big issue is that a new instance of HttpClient is created for each new request. This is enormously wasteful, as every time there likely to be an open connection going out of scope, which needs to be GC-ed in order to free up system resources. You should re-use HttpClient instance for multiple request and shut down its connection manager when it is no longer used. Besides, upgrading to Httpclient 4.0 may be a big jump, but there is no excuse for not upgrading to HttpClient 3.1 Oleg >> Sincerely, >> David Hamilton > > Hope that helps, > > Ortwin > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org For additional commands, e-mail: dev-help@hc.apache.org