Index: src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java =================================================================== --- src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java (revision 469254) +++ src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java (working copy) @@ -1056,7 +1056,7 @@ if(_maxIdle >= 0 && (pool.size() >= _maxIdle)) { shouldDestroy = true; } else if(success) { - pool.addLast(new ObjectTimestampPair(obj)); + pool.addFirst(new ObjectTimestampPair(obj)); _totalIdle++; } notifyAll(); @@ -1119,7 +1119,7 @@ if(_maxIdle >= 0 && (pool.size() >= _maxIdle)) { shouldDestroy = true; } else if(success) { - pool.addLast(new ObjectTimestampPair(obj)); + pool.addFirst(new ObjectTimestampPair(obj)); _totalIdle++; } notifyAll(); @@ -1207,17 +1207,10 @@ return; } key = keyIter.next(); + LinkedList list = (LinkedList)_poolMap.get(key); + objIter = list.listIterator(list.size()); } - // if we don't have a keyed object pool iterator - if (objIter == null) { - final LinkedList list = (LinkedList)_poolMap.get(key); - if (_evictLastIndex < 0 || _evictLastIndex > list.size()) { - _evictLastIndex = list.size(); - } - objIter = list.listIterator(_evictLastIndex); - } - // if the _evictionCursor has a previous object, then test it if(objIter.hasPrevious()) { ObjectTimestampPair pair = (ObjectTimestampPair)(objIter.previous()); @@ -1267,8 +1260,7 @@ } else { // else done evicting keyed pool _recentlyEvictedKeys.add(key); - _evictLastIndex = -1; - objIter = null; + key = null; } } } @@ -1668,9 +1660,4 @@ * Idle object pool keys that have been evicted recently. */ private Set _recentlyEvictedKeys = null; - - /** - * Position in the _pool where the _evictor last stopped. - */ - private int _evictLastIndex = -1; }