This is an automated email from the ASF dual-hosted git repository.

psteitz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-pool.git


The following commit(s) were added to refs/heads/master by this push:
     new 6eb494c  Add sync on PooledObject to make sure POOL-326 race does not 
recur.
6eb494c is described below

commit 6eb494c5f000138d37f2f1a0ab931327c14b83b6
Author: Phil Steitz <phil.ste...@gmail.com>
AuthorDate: Mon Oct 7 10:20:30 2019 -0700

    Add sync on PooledObject to make sure POOL-326 race does not recur.
---
 .../apache/commons/pool2/impl/GenericKeyedObjectPool.java | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git 
a/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java 
b/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
index 4cc69ed..f78a695 100644
--- a/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
+++ b/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
@@ -1086,12 +1086,15 @@ public class GenericKeyedObjectPool<K, T> extends 
BaseGenericObjectPool<T>
         final ObjectDeque<T> objectDeque = register(key);
 
         try {
-            // Check idle state directly
-            boolean isIdle = 
toDestroy.getState().equals(PooledObjectState.IDLE);
-            // If idle, not under eviction test, or always is true, remove 
instance,
-            // updating isIdle if instance is found in idle objects
-            if (isIdle || always) {
-                isIdle = objectDeque.getIdleObjects().remove(toDestroy);
+            boolean isIdle;
+            synchronized(toDestroy) {
+                // Check idle state directly
+                isIdle = toDestroy.getState().equals(PooledObjectState.IDLE);
+                // If idle, not under eviction test, or always is true, remove 
instance,
+                // updating isIdle if instance is found in idle objects
+                if (isIdle || always) {
+                    isIdle = objectDeque.getIdleObjects().remove(toDestroy);
+                }
             }
             if (isIdle || always) {
                 objectDeque.getAllObjects().remove(new 
IdentityWrapper<>(toDestroy.getObject()));

Reply via email to