commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sandy...@apache.org
Subject svn commit: r388706 - in /jakarta/commons/proper/pool/trunk/src: java/org/apache/commons/pool/composite/CompositeObjectPool.java test/org/apache/commons/pool/composite/TestCompositeObjectPool.java
Date Sat, 25 Mar 2006 05:30:49 GMT
Author: sandymac
Date: Fri Mar 24 21:30:47 2006
New Revision: 388706

URL: http://svn.apache.org/viewcvs?rev=388706&view=rev
Log:
Updates TestCompositeObjectPool to use Pool 2 contract tests in TestObjectPool.
CompositeObjectPool.addObject shouldn't swallow exceptions from PoolableObjectFactory.passivateObject

Modified:
    jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/CompositeObjectPool.java
    jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite/TestCompositeObjectPool.java

Modified: jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/CompositeObjectPool.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/CompositeObjectPool.java?rev=388706&r1=388705&r2=388706&view=diff
==============================================================================
--- jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/CompositeObjectPool.java
(original)
+++ jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/CompositeObjectPool.java
Fri Mar 24 21:30:47 2006
@@ -174,8 +174,14 @@
         assertOpen();
         synchronized (pool) {
             final Object obj = factory.makeObject();
-            tracker.borrowed(obj); // pretend it was borrowed so it can be returned.
-            returnObject(obj);
+            factory.passivateObject(obj);
+            // if the pool is closed, discard returned objects
+            if (isOpen()) {
+                manager.returnToPool(obj);
+            } else {
+                tracker.borrowed(obj); // pretend it was borrowed so it can be invalidated.
+                invalidateObject(obj);
+            }
         }
     }
 
@@ -243,10 +249,12 @@
         }
 
         synchronized (pool) {
-            tracker.returned(obj);
             // if the pool is closed, discard returned objects
             if (isOpen()) {
+                tracker.returned(obj);
                 manager.returnToPool(obj);
+            } else {
+                invalidateObject(obj);
             }
         }
     }

Modified: jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite/TestCompositeObjectPool.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite/TestCompositeObjectPool.java?rev=388706&r1=388705&r2=388706&view=diff
==============================================================================
--- jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite/TestCompositeObjectPool.java
(original)
+++ jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite/TestCompositeObjectPool.java
Fri Mar 24 21:30:47 2006
@@ -16,17 +16,17 @@
 
 package org.apache.commons.pool.composite;
 
-import junit.framework.TestCase;
 import org.apache.commons.pool.BasePoolableObjectFactory;
+import org.apache.commons.pool.ObjectPool;
 import org.apache.commons.pool.PoolableObjectFactory;
 import org.apache.commons.pool.TestObjectPool;
 
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
 import java.util.NoSuchElementException;
 import java.util.SortedSet;
 import java.util.TreeSet;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.LinkedList;
 
 /**
  * Test {@link CompositeObjectPool} and it's components.
@@ -35,9 +35,13 @@
  * @since #.#
  * @version $Revision$ $Date$
  */
-public class TestCompositeObjectPool extends TestCase {
+public class TestCompositeObjectPool extends TestObjectPool {
     private CompositeObjectPool pool = null;
 
+    public TestCompositeObjectPool(final String testName) {
+        super(testName);
+    }
+
     public void setUp() throws Exception {
     }
 
@@ -46,6 +50,11 @@
             pool.close();
             pool = null;
         }
+    }
+
+    protected ObjectPool makeEmptyPool(final PoolableObjectFactory factory) {
+        final CompositeObjectPoolFactory copf = new CompositeObjectPoolFactory(factory);
+        return copf.createPool();
     }
 
     // Test Managers --------------------------------------



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


Mime
View raw message