hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
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 GMT
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 <olegk at apache.org>
+
+
+
 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<T, C> callback) {
         this.lock.lock();
         try {
-            enumEntries(this.available.iterator(), callback);
+            final Iterator<E> it = this.available.iterator();
+            while (it.hasNext()) {
+                final E entry = it.next();
+                callback.process(entry);
+                if (entry.isClosed()) {
+                    final RouteSpecificPool<T, C, E> 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<T, C> callback) {
         this.lock.lock();
         try {
-            enumEntries(this.leased.iterator(), callback);
+            final Iterator<E> 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<E> it, final PoolEntryCallback<T,
C> callback) {
         while (it.hasNext()) {
             final E entry = it.next();
             callback.process(entry);
-            if (entry.isClosed()) {
-                final RouteSpecificPool<T, C, E> 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<T
     protected void enumAvailable(final PoolEntryCallback<T, C> callback) {
         this.lock.lock();
         try {
-            enumEntries(this.available.iterator(), callback);
+            final Iterator<E> it = this.available.iterator();
+            while (it.hasNext()) {
+                final E entry = it.next();
+                callback.process(entry);
+                if (entry.isClosed()) {
+                    final RouteSpecificPool<T, C, E> pool = getPool(entry.getRoute());
+                    pool.remove(entry);
+                    it.remove();
+                }
+            }
+            purgePoolMap();
         } finally {
             this.lock.unlock();
         }
@@ -445,24 +455,16 @@ public abstract class AbstractConnPool<T
     protected void enumLeased(final PoolEntryCallback<T, C> callback) {
         this.lock.lock();
         try {
-            enumEntries(this.leased.iterator(), callback);
+            final Iterator<E> it = this.leased.iterator();
+            while (it.hasNext()) {
+                final E entry = it.next();
+                callback.process(entry);
+            }
         } finally {
             this.lock.unlock();
         }
     }
 
-    private void enumEntries(final Iterator<E> it, final PoolEntryCallback<T, C>
callback) {
-        while (it.hasNext()) {
-            final E entry = it.next();
-            callback.process(entry);
-            if (entry.isClosed()) {
-                final RouteSpecificPool<T, C, E> pool = getPool(entry.getRoute());
-                pool.remove(entry);
-                it.remove();
-            }
-        }
-    }
-
     private void purgePoolMap() {
         final Iterator<Map.Entry<T, RouteSpecificPool<T, C, E>>> it = this.routeToPool.entrySet().iterator();
         while (it.hasNext()) {
@@ -497,7 +499,6 @@ public abstract class AbstractConnPool<T
             }
 
         });
-        purgePoolMap();
     }
 
     /**
@@ -514,7 +515,6 @@ public abstract class AbstractConnPool<T
             }
 
         });
-        purgePoolMap();
     }
 
     @Override



Mime
View raw message