hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject [03/34] httpcomponents-core git commit: (Regression) Fixed synchronization issue in blocking and non-blocking connection pool implementations caused by HTTPCORE-362
Date Tue, 09 May 2017 20:02:32 GMT
(Regression) Fixed synchronization issue in blocking and non-blocking connection pool implementations
caused by HTTPCORE-362

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.3.x@1558755
13f79535-47bb-0310-9956-ffa450edef68


Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/68a42581
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/68a42581
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/68a42581

Branch: refs/heads/4.3.x
Commit: 68a425816b1b563949ebbbac076642b9d83f5afd
Parents: 6289707
Author: Oleg Kalnichevski <olegk@apache.org>
Authored: Thu Jan 16 11:03:02 2014 +0000
Committer: Oleg Kalnichevski <olegk@apache.org>
Committed: Thu Jan 16 11:03:02 2014 +0000

----------------------------------------------------------------------
 RELEASE_NOTES.txt                               |  9 +++++
 .../http/nio/pool/AbstractNIOConnPool.java      | 35 ++++++++++++++------
 .../org/apache/http/pool/AbstractConnPool.java  | 32 +++++++++---------
 3 files changed, 50 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/68a42581/RELEASE_NOTES.txt
----------------------------------------------------------------------
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index 8b7f2d7..ed3ead2 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -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
 -------------------
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/68a42581/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java
b/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java
index fbdc927..7b68eca 100644
--- a/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java
+++ b/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java
@@ -655,7 +655,18 @@ public abstract class AbstractNIOConnPool<T, C, E extends PoolEntry<T,
C>>
     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 AbstractNIOConnPool<T, C, E extends PoolEntry<T,
C>>
     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 AbstractNIOConnPool<T, C, E extends PoolEntry<T,
C>>
             }
 
         });
-        purgePoolMap();
     }
 
     public void closeExpired() {
@@ -730,7 +746,6 @@ public abstract class AbstractNIOConnPool<T, C, E extends PoolEntry<T,
C>>
             }
 
         });
-        purgePoolMap();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/68a42581/httpcore/src/main/java/org/apache/http/pool/AbstractConnPool.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/pool/AbstractConnPool.java b/httpcore/src/main/java/org/apache/http/pool/AbstractConnPool.java
index a6ac1de..a2c3103 100644
--- a/httpcore/src/main/java/org/apache/http/pool/AbstractConnPool.java
+++ b/httpcore/src/main/java/org/apache/http/pool/AbstractConnPool.java
@@ -431,7 +431,17 @@ public abstract class AbstractConnPool<T, C, E extends PoolEntry<T,
C>>
     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, C, E extends PoolEntry<T,
C>>
     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, C, E extends PoolEntry<T,
C>>
             }
 
         });
-        purgePoolMap();
     }
 
     /**
@@ -514,7 +515,6 @@ public abstract class AbstractConnPool<T, C, E extends PoolEntry<T,
C>>
             }
 
         });
-        purgePoolMap();
     }
 
     @Override


Mime
View raw message