Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 82374 invoked from network); 13 Jun 2006 08:35:26 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 13 Jun 2006 08:35:25 -0000 Received: (qmail 2318 invoked by uid 500); 13 Jun 2006 08:35:23 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 2058 invoked by uid 500); 13 Jun 2006 08:35:21 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 2047 invoked by uid 500); 13 Jun 2006 08:35:21 -0000 Received: (qmail 2044 invoked by uid 99); 13 Jun 2006 08:35:21 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Jun 2006 01:35:21 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Jun 2006 01:35:20 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id AD7F11A983A; Tue, 13 Jun 2006 01:35:00 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r413837 - /jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/SimpleHttpConnectionManager.java Date: Tue, 13 Jun 2006 08:35:00 -0000 To: commons-cvs@jakarta.apache.org From: olegk@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060613083500.AD7F11A983A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: olegk Date: Tue Jun 13 01:35:00 2006 New Revision: 413837 URL: http://svn.apache.org/viewvc?rev=413837&view=rev Log: [HTTPCLIENT-420] Provide a non-pooling connection manager Changelog: Added an option to the simple connection manager to disable connection persistence Contributed by Oleg Kalnichevski Reviewed by Roland Weber and Michael Becke Modified: jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/SimpleHttpConnectionManager.java Modified: jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/SimpleHttpConnectionManager.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/SimpleHttpConnectionManager.java?rev=413837&r1=413836&r2=413837&view=diff ============================================================================== --- jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/SimpleHttpConnectionManager.java (original) +++ jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/SimpleHttpConnectionManager.java Tue Jun 13 01:35:00 2006 @@ -71,7 +71,6 @@ try { lastResponse.close(); } catch (IOException ioe) { - //FIXME: badness - close to force reconnect. conn.close(); } } @@ -97,8 +96,29 @@ * It will not be used to enforce thread safety. */ private volatile boolean inUse = false; + + private boolean alwaysClose = false; + + /** + * The connection manager created with this constructor will try to keep the + * connection open (alive) between consecutive requests if the alwaysClose + * parameter is set to false. Otherwise the connection manager will + * always close connections upon release. + * + * @param alwaysClose if set true, the connection manager will always + * close connections upon release. + */ + public SimpleHttpConnectionManager(boolean alwaysClose) { + super(); + this.alwaysClose = alwaysClose; + } + /** + * The connection manager created with this constructor will always try to keep + * the connection open (alive) between consecutive requests. + */ public SimpleHttpConnectionManager() { + super(); } /** @@ -203,8 +223,12 @@ if (conn != httpConnection) { throw new IllegalStateException("Unexpected release of an unknown connection."); } - - finishLastResponse(httpConnection); + if (this.alwaysClose) { + httpConnection.close(); + } else { + // make sure the connection is reuseable + finishLastResponse(httpConnection); + } inUse = false; --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org