Return-Path: X-Original-To: apmail-hc-commits-archive@www.apache.org Delivered-To: apmail-hc-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2583E10AC7 for ; Thu, 16 Jan 2014 11:03:36 +0000 (UTC) Received: (qmail 58702 invoked by uid 500); 16 Jan 2014 11:03:35 -0000 Delivered-To: apmail-hc-commits-archive@hc.apache.org Received: (qmail 58642 invoked by uid 500); 16 Jan 2014 11:03:29 -0000 Mailing-List: contact commits-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 commits@hc.apache.org Received: (qmail 58634 invoked by uid 99); 16 Jan 2014 11:03:27 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Jan 2014 11:03:27 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Jan 2014 11:03:24 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 7EBBF238883D for ; Thu, 16 Jan 2014 11:03:03 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1558755 - in /httpcomponents/httpcore/branches/4.3.x: RELEASE_NOTES.txt httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java httpcore/src/main/java/org/apache/http/pool/AbstractConnPool.java Date: Thu, 16 Jan 2014 11:03:03 -0000 To: commits@hc.apache.org From: olegk@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140116110303.7EBBF238883D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: olegk Date: Thu Jan 16 11:03:02 2014 New Revision: 1558755 URL: http://svn.apache.org/r1558755 Log: (Regression) Fixed synchronization issue in blocking and non-blocking connection pool implementations caused by HTTPCORE-362 Modified: httpcomponents/httpcore/branches/4.3.x/RELEASE_NOTES.txt httpcomponents/httpcore/branches/4.3.x/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java httpcomponents/httpcore/branches/4.3.x/httpcore/src/main/java/org/apache/http/pool/AbstractConnPool.java Modified: httpcomponents/httpcore/branches/4.3.x/RELEASE_NOTES.txt URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/4.3.x/RELEASE_NOTES.txt?rev=1558755&r1=1558754&r2=1558755&view=diff ============================================================================== --- httpcomponents/httpcore/branches/4.3.x/RELEASE_NOTES.txt (original) +++ httpcomponents/httpcore/branches/4.3.x/RELEASE_NOTES.txt Thu Jan 16 11:03:02 2014 @@ -1,3 +1,12 @@ +Changes since release 4.3.1 +------------------- + +* (Regression) Fixed synchronization issue in blocking and non-blocking connection pool + implementations caused by HTTPCORE-362 + Contributed by Oleg Kalnichevski + + + Release 4.3.1 ------------------- Modified: httpcomponents/httpcore/branches/4.3.x/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/4.3.x/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java?rev=1558755&r1=1558754&r2=1558755&view=diff ============================================================================== --- httpcomponents/httpcore/branches/4.3.x/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java (original) +++ httpcomponents/httpcore/branches/4.3.x/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java Thu Jan 16 11:03:02 2014 @@ -655,7 +655,18 @@ public abstract class AbstractNIOConnPoo protected void enumAvailable(final PoolEntryCallback callback) { this.lock.lock(); try { - enumEntries(this.available.iterator(), callback); + final Iterator it = this.available.iterator(); + while (it.hasNext()) { + final E entry = it.next(); + callback.process(entry); + if (entry.isClosed()) { + final RouteSpecificPool pool = getPool(entry.getRoute()); + pool.remove(entry); + it.remove(); + } + } + processPendingRequests(); + purgePoolMap(); } finally { this.lock.unlock(); } @@ -669,22 +680,28 @@ public abstract class AbstractNIOConnPoo protected void enumLeased(final PoolEntryCallback callback) { this.lock.lock(); try { - enumEntries(this.leased.iterator(), callback); + final Iterator it = this.leased.iterator(); + while (it.hasNext()) { + final E entry = it.next(); + callback.process(entry); + } + processPendingRequests(); } finally { this.lock.unlock(); } } - //TODO: this method should be private + /** + * Use {@link #enumLeased(org.apache.http.pool.PoolEntryCallback)} + * or {@link #enumAvailable(org.apache.http.pool.PoolEntryCallback)} instead. + * + * @deprecated (4.3.2) + */ + @Deprecated protected void enumEntries(final Iterator it, final PoolEntryCallback callback) { while (it.hasNext()) { final E entry = it.next(); callback.process(entry); - if (entry.isClosed()) { - final RouteSpecificPool pool = getPool(entry.getRoute()); - pool.remove(entry); - it.remove(); - } } processPendingRequests(); } @@ -716,7 +733,6 @@ public abstract class AbstractNIOConnPoo } }); - purgePoolMap(); } public void closeExpired() { @@ -730,7 +746,6 @@ public abstract class AbstractNIOConnPoo } }); - purgePoolMap(); } @Override Modified: httpcomponents/httpcore/branches/4.3.x/httpcore/src/main/java/org/apache/http/pool/AbstractConnPool.java URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/4.3.x/httpcore/src/main/java/org/apache/http/pool/AbstractConnPool.java?rev=1558755&r1=1558754&r2=1558755&view=diff ============================================================================== --- httpcomponents/httpcore/branches/4.3.x/httpcore/src/main/java/org/apache/http/pool/AbstractConnPool.java (original) +++ httpcomponents/httpcore/branches/4.3.x/httpcore/src/main/java/org/apache/http/pool/AbstractConnPool.java Thu Jan 16 11:03:02 2014 @@ -431,7 +431,17 @@ public abstract class AbstractConnPool callback) { this.lock.lock(); try { - enumEntries(this.available.iterator(), callback); + final Iterator it = this.available.iterator(); + while (it.hasNext()) { + final E entry = it.next(); + callback.process(entry); + if (entry.isClosed()) { + final RouteSpecificPool pool = getPool(entry.getRoute()); + pool.remove(entry); + it.remove(); + } + } + purgePoolMap(); } finally { this.lock.unlock(); } @@ -445,24 +455,16 @@ public abstract class AbstractConnPool callback) { this.lock.lock(); try { - enumEntries(this.leased.iterator(), callback); + final Iterator it = this.leased.iterator(); + while (it.hasNext()) { + final E entry = it.next(); + callback.process(entry); + } } finally { this.lock.unlock(); } } - private void enumEntries(final Iterator it, final PoolEntryCallback callback) { - while (it.hasNext()) { - final E entry = it.next(); - callback.process(entry); - if (entry.isClosed()) { - final RouteSpecificPool pool = getPool(entry.getRoute()); - pool.remove(entry); - it.remove(); - } - } - } - private void purgePoolMap() { final Iterator>> it = this.routeToPool.entrySet().iterator(); while (it.hasNext()) { @@ -497,7 +499,6 @@ public abstract class AbstractConnPool