--- GenericObjectPool.beforePatch.java 2007-04-23 15:20:53.629902600 +0200 +++ GenericObjectPool.java 2007-04-23 15:31:15.000000000 +0200 @@ -957,7 +957,7 @@ return _pool.size(); } - public synchronized void returnObject(Object obj) throws Exception { + public void returnObject(Object obj) throws Exception { try { addObjectToPool(obj, true); } catch (Exception e) { @@ -982,17 +982,17 @@ } boolean shouldDestroy = !success; - - if (decrementNumActive) { - _numActive--; - } - if((_maxIdle >= 0) && (_pool.size() >= _maxIdle)) { - shouldDestroy = true; - } else if(success) { - _pool.addLast(new ObjectTimestampPair(obj)); - } - notifyAll(); // _numActive has changed - + synchronized (this) { + if (decrementNumActive) { + _numActive--; + } + if ((_maxIdle >= 0) && (_pool.size() >= _maxIdle)) { + shouldDestroy = true; + } else if (success) { + _pool.addLast(new ObjectTimestampPair(obj)); + } + notifyAll(); // _numActive has changed + } if(shouldDestroy) { try { // TODO: remove try/catch _factory.destroyObject(obj); @@ -1122,7 +1122,7 @@ * Create an object, and place it into the pool. * addObject() is useful for "pre-loading" a pool with idle objects. */ - public synchronized void addObject() throws Exception { + public void addObject() throws Exception { assertOpen(); if (_factory == null) { throw new IllegalStateException("Cannot add objects without a factory.");