commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Phil Steitz <phil.ste...@gmail.com>
Subject Re: svn commit: r781288 - /commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java
Date Wed, 03 Jun 2009 10:09:36 GMT
markt@apache.org wrote:
> Author: markt
> Date: Wed Jun  3 07:52:20 2009
> New Revision: 781288
>
> URL: http://svn.apache.org/viewvc?rev=781288&view=rev
> Log:
> Fix root cause of error reported by sebb with testEvictorVisiting() on the dev list.
> When adding objects to the toDestroy list, need to remove them from the pool to ensure
cursors are kept up to date. Make all places where this happens consistent with each other
and, as much as possible, GOP as well.
>   
This makes sense to me and explains why the first - incorrect - fix I 
committed cleared the problem. 

Phil
> 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=781288&r1=781287&r2=781288&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
Wed Jun  3 07:52:20 2009
> @@ -1284,12 +1284,17 @@
>              for (Iterator it = _poolMap.keySet().iterator(); it.hasNext();) {
>                  Object key = it.next();
>                  ObjectQueue pool = (ObjectQueue)_poolMap.get(key);
> -                toDestroy.put(key, pool.queue);
> +                // Copy objects to new list so pool.queue can be cleared inside
> +                // the sync
> +                List objects = new ArrayList();
> +                objects.addAll(pool.queue);
> +                toDestroy.put(key, objects);
>                  it.remove();
>                  _poolList.remove(key);
>                  _totalIdle = _totalIdle - pool.queue.size();
>                  _totalInternalProcessing =
>                      _totalInternalProcessing + pool.queue.size();
> +                pool.queue.clear();
>              }
>          }
>          destroy(toDestroy);
> @@ -1372,10 +1377,15 @@
>              } else {
>                  _poolList.remove(key);
>              }
> +            // Copy objects to new list so pool.queue can be cleared inside
> +            // the sync
> +            List objects = new ArrayList();
> +            objects.addAll(pool.queue);
> +            toDestroy.put(key, objects);
>              _totalIdle = _totalIdle - pool.queue.size();
>              _totalInternalProcessing =
>                  _totalInternalProcessing + pool.queue.size();
> -            toDestroy.put(key, pool.queue);
> +            pool.queue.clear();
>          }
>          destroy(toDestroy);
>      }
> @@ -1701,12 +1711,17 @@
>                      Object key = it.next();
>                      ObjectQueue pool = (ObjectQueue)_poolMap.get(key);
>                      if (pool != null) {
> -                        toDestroy.put(key, pool.queue);
> +                        // Copy objects to new list so pool.queue can be cleared
> +                        // inside the sync
> +                        List objects = new ArrayList();
> +                        objects.addAll(pool.queue);
> +                        toDestroy.put(key, objects);
>                          it.remove();
>                          _poolList.remove(key);
>                          _totalIdle = _totalIdle - pool.queue.size();
>                          _totalInternalProcessing =
>                              _totalInternalProcessing + pool.queue.size();
> +                        pool.queue.clear();
>                      }
>                  }
>                  _factory = factory;
>
>
>   


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


Mime
View raw message