dirkv 2004/04/27 13:15:56 Modified: pool/src/java/org/apache/commons/pool/impl GenericObjectPool.java Log: Bugzilla Bug 28638: Not possible to extend GenericObjectPool.returnObject() without affecting addObject() - remove the slimy dependency between the two methods ;-) Revision Changes Path 1.32 +9 -6 jakarta-commons/pool/src/java/org/apache/commons/pool/impl/GenericObjectPool.java Index: GenericObjectPool.java =================================================================== RCS file: /home/cvs/jakarta-commons/pool/src/java/org/apache/commons/pool/impl/GenericObjectPool.java,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- GenericObjectPool.java 28 Feb 2004 11:46:33 -0000 1.31 +++ GenericObjectPool.java 27 Apr 2004 20:15:56 -0000 1.32 @@ -851,6 +851,10 @@ public void returnObject(Object obj) throws Exception { assertOpen(); + addObjectToPool(obj, true); + } + + private void addObjectToPool(Object obj, boolean decrementNumActive) throws Exception { boolean success = true; if(_testOnReturn && !(_factory.validateObject(obj))) { success = false; @@ -865,7 +869,9 @@ boolean shouldDestroy = !success; synchronized(this) { - _numActive--; + if (decrementNumActive) { + _numActive--; + } if((_maxIdle >= 0) && (_pool.size() >= _maxIdle)) { shouldDestroy = true; } else if(success) { @@ -988,10 +994,7 @@ */ public void addObject() throws Exception { Object obj = _factory.makeObject(); - synchronized(this) { - _numActive++; // A little slimy - must do this because returnObject decrements it. - this.returnObject(obj); - } + addObjectToPool(obj, false); } //--- non-public methods ----------------------------------------
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]