You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ma...@apache.org on 2009/06/02 23:01:35 UTC

svn commit: r781166 - /commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java

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);



Re: svn commit: r781166 - /commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java

Posted by Mark Thomas <ma...@apache.org>.
sebb wrote:
> On 02/06/2009, Mark Thomas <ma...@apache.org> wrote:
>> markt@apache.org wrote:
>>  > 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.
>>
>>
>> Hmm. The cursors really should handle this. May be a cursor bug?
> 
> The GKOP _poolMap and _poolList fields are not tied together, so it is
> possible for them to get out of step. Maybe they should be wrapped up
> in a separate class that ensures they are kept in step.

Maybe. Unless you can see somewhere this is an issue, I'm inclined to
leave this alone until we figure out the root cause of this bug. I don't
think, at the moment, it is worth the risk of introducing another subtle
bug/bugs.

Mark



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: svn commit: r781166 - /commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java

Posted by sebb <se...@gmail.com>.
On 02/06/2009, Mark Thomas <ma...@apache.org> wrote:
> markt@apache.org wrote:
>  > 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.
>
>
> Hmm. The cursors really should handle this. May be a cursor bug?

The GKOP _poolMap and _poolList fields are not tied together, so it is
possible for them to get out of step. Maybe they should be wrapped up
in a separate class that ensures they are kept in step.

The GOP class only has one field for the pool, so it's easier to keep
track of it.

>  Mark
>
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>  For additional commands, e-mail: dev-help@commons.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: svn commit: r781166 - /commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java

Posted by Mark Thomas <ma...@apache.org>.
markt@apache.org wrote:
> 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.

Hmm. The cursors really should handle this. May be a cursor bug?

Mark



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org