Author: markt
Date: Tue Jun 2 21:01:34 2009
New Revision: 781166
URL: http://svn.apache.org/viewvc?rev=781166&view=rev
Log:
Anything that clears the pool is likely to mess up the eviction cursors. This
fixes the issue sebb reported with testEvictorVisiting() on the dev list.
Modified:
commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java
Modified:
commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java
URL:
http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java?rev=781166&r1=781165&r2=781166&view=diff
==============================================================================
---
commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java
(original)
+++
commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java
Tue Jun 2 21:01:34 2009
@@ -1291,6 +1291,9 @@
_totalInternalProcessing =
_totalInternalProcessing + pool.queue.size();
}
+ // Reset the eviction cursors as clearing the objects will have
+ // invalidated the current cursors
+ resetEvictionKeyCursor();
}
destroy(toDestroy);
}
@@ -1352,6 +1355,9 @@
itemsToRemove--;
}
+ // Reset the eviction cursors as clearing the objects will have
+ // invalidated the current cursors
+ resetEvictionKeyCursor();
}
destroy(toDestroy);
}
@@ -1376,6 +1382,10 @@
_totalInternalProcessing =
_totalInternalProcessing + pool.queue.size();
toDestroy.put(key, pool.queue);
+
+ // Reset the eviction cursors as clearing the objects may have
+ // invalidated the current cursors
+ resetEvictionKeyCursor();
}
destroy(toDestroy);
}
@@ -1385,6 +1395,11 @@
* ObjectTimestampPair.value
*
* @param m Map containing keyed pools to clear
+
+ * Implementation note: This is called just outside a sync block where
+ * objects are removed from the pool for destruction. This process is
likely
+ * to invalidate any eviction cursors. Therefore, the last call inside the
+ * sync block should be to resetEvictionKeyCursor().
*/
private void destroy(Map m) {
for (Iterator keys = m.keySet().iterator(); keys.hasNext();) {
@@ -1710,6 +1725,7 @@
}
}
_factory = factory;
+ resetEvictionKeyCursor();
}
}
destroy(toDestroy);