Author: sandymac
Date: Thu Mar 23 21:30:41 2006
New Revision: 388382

URL: http://svn.apache.org/viewcvs?rev=388382&view=rev
Log:
many JavaDoc clean ups
behavior chages for pool 2 contracts
key handling fixes for close and clear methods in CompositeKeyedObjectPool

Modified:
    
jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/AbstractManager.java
    
jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/CompositeKeyedObjectPool.java
    
jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/CompositeObjectPool.java
    
jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/DelegateManager.java
    
jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/IdleLimitManager.java
    
jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/KeyedPoolableObjectFactoryAdapter.java
    
jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/Manager.java
    
jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/NullTracker.java
    
jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/Tracker.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/AbstractManager.java
URL: 
http://svn.apache.org/viewcvs/jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/AbstractManager.java?rev=388382&r1=388381&r2=388382&view=diff
==============================================================================
--- 
jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/AbstractManager.java
 (original)
+++ 
jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/AbstractManager.java
 Thu Mar 23 21:30:41 2006
@@ -70,9 +70,8 @@
      * Return an object to the pool. Object will be [EMAIL PROTECTED] 
PoolableObjectFactory#passivateObject(Object) passivated}.
      *
      * @param obj the object to return to the pool.
-     * @throws Exception as thrown by [EMAIL PROTECTED] 
PoolableObjectFactory#passivateObject(Object)}.
      */
-    public void returnToPool(final Object obj) throws Exception {
+    public void returnToPool(final Object obj) {
         assert Thread.holdsLock(objectPool.getPool());
         objectPool.getLender().repay(obj);
     }

Modified: 
jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/CompositeKeyedObjectPool.java
URL: 
http://svn.apache.org/viewcvs/jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/CompositeKeyedObjectPool.java?rev=388382&r1=388381&r2=388382&view=diff
==============================================================================
--- 
jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/CompositeKeyedObjectPool.java
 (original)
+++ 
jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/CompositeKeyedObjectPool.java
 Thu Mar 23 21:30:41 2006
@@ -106,18 +106,15 @@
     }
 
     /**
-     * Obtain an instance from my pool
-     * for the specified <i>key</i>.
-     * By contract, clients MUST return
-     * the borrowed object using
-     * [EMAIL PROTECTED] #returnObject(Object,Object) <tt>returnObject</tt>},
-     * or a related method as defined in an implementation
-     * or sub-interface,
-     * using a <i>key</i> that is equivalent to the one used to
+     * Obtain an instance from this pool for the specified <code>key</code>.
+     * By contract, clients <strong>must</strong> return the borrowed object 
using
+     * [EMAIL PROTECTED] #returnObject(Object,Object) 
<code>returnObject</code>},
+     * or a related method as defined in an implementation or sub-interface,
+     * using a <code>key</code> that is equivalent to the one used to
      * borrow the instance in the first place.
      *
      * @param key the key used to obtain the object
-     * @return an instance from my pool.
+     * @return an instance from this pool.
      * @throws Exception if there is an unexpected problem.
      */
     public Object borrowObject(final Object key) throws Exception {
@@ -136,26 +133,26 @@
     }
 
     /**
-     * Return an instance to my pool.
-     * By contract, <i>obj</i> MUST have been obtained
-     * using [EMAIL PROTECTED] #borrowObject(Object) <tt>borrowObject</tt>}
-     * or a related method as defined in an implementation
-     * or sub-interface
-     * using a <i>key</i> that is equivalent to the one used to
-     * borrow the <tt>Object</tt> in the first place.
+     * Return an instance to this pool. By contract, <code>obj</code>
+     * <strong>must</strong> have been obtained using
+     * [EMAIL PROTECTED] #borrowObject borrowObject} or a related method as 
defined
+     * in an implementation or sub-interface using a <code>key</code> that
+     * is equivalent to the one used to borrow the <code>Object</code> in
+     * the first place.
      *
      * @param key the key used to obtain the object
-     * @param obj a [EMAIL PROTECTED] #borrowObject(Object) borrowed} instance 
to be returned.
-     * @throws Exception if there is an unexpected problem.
+     * @param obj a [EMAIL PROTECTED] #borrowObject borrowed} instance to be 
returned.
      */
-    public void returnObject(final Object key, final Object obj) throws 
Exception {
-        assertOpen();
+    public void returnObject(final Object key, final Object obj) {
         final ObjectPool pool = getObjectPool(key);
         try {
             if (keys != null) {
                 keys.set(key);
             }
             pool.returnObject(obj);
+        } catch (Exception e) {
+            // swallowed
+            // XXX: In pool 3 this catch block will not be necessary and 
shouled be removed
         } finally {
             if (keys != null) {
                 keys.set(null); // unset key
@@ -164,32 +161,33 @@
     }
 
     /**
-     * Invalidates an object from the pool
-     * By contract, <i>obj</i> MUST have been obtained
-     * using [EMAIL PROTECTED] #borrowObject borrowObject}
-     * or a related method as defined in an implementation
-     * or sub-interface
-     * using a <i>key</i> that is equivalent to the one used to
-     * borrow the <tt>Object</tt> in the first place.
+     * Invalidates an object from this pool. By contract, <code>obj</code>
+     * <strong>must</strong> have been obtained using
+     * [EMAIL PROTECTED] #borrowObject borrowObject} or a related method as 
defined
+     * in an implementation or sub-interface using a <code>key</code> that
+     * is equivalent to the one used to borrow the <code>Object</code> in
+     * the first place.
      * <p>
      * This method should be used when an object that has been borrowed
      * is determined (due to an exception or other problem) to be invalid.
      * If the connection should be validated before or after borrowing,
      * then the [EMAIL PROTECTED] PoolableObjectFactory#validateObject} method 
should be
      * used instead.
+     * </p>
      *
      * @param key the key used to obtain the object
      * @param obj a [EMAIL PROTECTED] #borrowObject borrowed} instance to be 
returned.
-     * @throws Exception if there is an unexpected problem.
      */
-    public void invalidateObject(final Object key, final Object obj) throws 
Exception {
-        assertOpen();
+    public void invalidateObject(final Object key, final Object obj) {
         final ObjectPool pool = getObjectPool(key);
         try {
             if (keys != null) {
                 keys.set(key);
             }
             pool.invalidateObject(obj);
+        } catch (Exception e) {
+            // swallowed
+            // XXX: In pool 3 this catch block will not be necessary and 
shouled be removed
         } finally {
             if (keys != null) {
                 keys.set(null); // unset key
@@ -198,10 +196,8 @@
     }
 
     /**
-     * Create an object using my [EMAIL PROTECTED] #setFactory factory} or 
other
-     * implementation dependent mechanism, and place it into the pool.
-     * addObject() is useful for "pre-loading" a pool with idle objects.
-     * (Optional operation).
+     * Create an object using the [EMAIL PROTECTED] #setFactory factory} and 
place it into the pool.
+     * <code>addObject</code> is useful for "pre-loading" a pool with idle 
objects.
      *
      * @param key the key used to obtain the object
      * @throws Exception if there is an unexpected problem.
@@ -222,18 +218,12 @@
     }
 
     /**
-     * Returns the number of instances
-     * corresponding to the given <i>key</i>
-     * currently idle in my pool (optional operation).
-     * Throws [EMAIL PROTECTED] UnsupportedOperationException}
-     * if this information is not available.
+     * Returns the number of instances corresponding to the given 
<code>key</code> currently idle in this pool.
      *
      * @param key the key
-     * @return the number of instances corresponding to the given <i>key</i> 
currently idle in my pool
-     * @throws UnsupportedOperationException when this implementation doesn't 
support the operation
+     * @return the number of instances corresponding to the given 
<code>key</code> currently idle in this pool
      */
-    public int getNumIdle(final Object key) throws 
UnsupportedOperationException {
-        assertOpen();
+    public int getNumIdle(final Object key) {
         final ObjectPool pool = getObjectPool(key);
         try {
             if (keys != null) {
@@ -250,17 +240,13 @@
     /**
      * Returns the number of instances
      * currently borrowed from but not yet returned
-     * to my pool corresponding to the
-     * given <i>key</i> (optional operation).
-     * Throws [EMAIL PROTECTED] UnsupportedOperationException}
-     * if this information is not available.
+     * to this pool corresponding to the
+     * given <code>key</code>.
      *
      * @param key the key
-     * @return the number of instances corresponding to the given <i>key</i> 
currently borrowed in my pool
-     * @throws UnsupportedOperationException when this implementation doesn't 
support the operation
+     * @return the number of instances corresponding to the given 
<code>key</code> currently borrowed in this pool
      */
-    public int getNumActive(final Object key) throws 
UnsupportedOperationException {
-        assertOpen();
+    public int getNumActive(final Object key) {
         final ObjectPool pool = getObjectPool(key);
         try {
             if (keys != null) {
@@ -275,16 +261,11 @@
     }
 
     /**
-     * Returns the total number of instances
-     * currently idle in my pool (optional operation).
-     * Throws [EMAIL PROTECTED] UnsupportedOperationException}
-     * if this information is not available.
+     * Returns the total number of instances currently idle in this pool.
      *
-     * @return the total number of instances currently idle in my pool
-     * @throws UnsupportedOperationException when this implementation doesn't 
support the operation
+     * @return the total number of instances currently idle in this pool
      */
-    public int getNumIdle() throws UnsupportedOperationException {
-        assertOpen();
+    public int getNumIdle() {
         int numIdle = 0;
         synchronized (objectPools) {
             final Iterator iter = objectPools.values().iterator();
@@ -297,17 +278,12 @@
     }
 
     /**
-     * Returns the total number of instances
-     * current borrowed from my pool but not
-     * yet returned (optional operation).
-     * Throws [EMAIL PROTECTED] UnsupportedOperationException}
-     * if this information is not available.
+     * Returns the total number of instances current borrowed
+     * from this pool but not yet returned.
      *
-     * @return the total number of instances currently borrowed from my pool
-     * @throws UnsupportedOperationException when this implementation doesn't 
support the operation
+     * @return the total number of instances currently borrowed from this pool
      */
-    public int getNumActive() throws UnsupportedOperationException {
-        assertOpen();
+    public int getNumActive() {
         int numActive = 0;
         synchronized (objectPools) {
             final Iterator iter = objectPools.values().iterator();
@@ -320,43 +296,42 @@
     }
 
     /**
-     * Clears my pool, removing all pooled instances
-     * (optional operation).
-     * Throws [EMAIL PROTECTED] UnsupportedOperationException}
-     * if the pool cannot be cleared.
+     * Clears this pool, removing all pooled instances.
      *
-     * @throws UnsupportedOperationException when this implementation doesn't 
support the operation
      * @throws Exception if there is an unexpected problem.
      */
-    public void clear() throws Exception, UnsupportedOperationException {
+    public void clear() throws Exception {
         synchronized (objectPools) {
-            final Iterator iter = objectPools.values().iterator();
+            final Iterator iter = objectPools.keySet().iterator();
             while (iter.hasNext()) {
-                final ObjectPool pool = (ObjectPool)iter.next();
-                pool.clear();
+                final Object key = iter.next();
+                clear(key);
             }
         }
     }
 
     /**
-     * Clears the specified pool, removing all
-     * pooled instances corresponding to
-     * the given <i>key</i>  (optional operation).
-     * Throws [EMAIL PROTECTED] UnsupportedOperationException}
-     * if the pool cannot be cleared.
+     * Clears the specified pool, removing all pooled instances
+     * corresponding to the given <code>key</code>.
      *
      * @param key the key to clear
-     * @throws UnsupportedOperationException when this implementation doesn't 
support the operation
      * @throws Exception if there is an unexpected problem.
      */
-    public void clear(final Object key) throws Exception, 
UnsupportedOperationException {
-        assertOpen();
+    public void clear(final Object key) throws Exception {
         final ObjectPool pool = getObjectPool(key);
         try {
             if (keys != null) {
                 keys.set(key);
             }
             pool.clear();
+
+            // Remove this pool if we know no more active objects will be 
returned.
+            synchronized (objectPools) {
+                if (pool.getNumActive() == 0) {
+                    objectPools.remove(key);
+                    pool.close();
+                }
+            }
         } finally {
             if (keys != null) {
                 keys.set(null); // unset key
@@ -366,18 +341,40 @@
 
     /**
      * Close this pool, and free any resources associated with it.
-     *
-     * @throws Exception if there is an unexpected problem.
      */
-    public void close() throws Exception {
+    public void close() {
         open = false;
         Thread.yield(); // encourage any threads currently executing in the 
pool to finish first.
         synchronized (objectPools) {
-            final Iterator iter = objectPools.values().iterator();
+            final Iterator iter = objectPools.keySet().iterator();
             while (iter.hasNext()) {
-                final ObjectPool pool = (ObjectPool)iter.next();
-                pool.close();
-                iter.remove();
+                final Object key = iter.next();
+                close(key);
+            }
+        }
+    }
+
+    private void close(final Object key) {
+        final ObjectPool pool = getObjectPool(key);
+        try {
+            if (keys != null) {
+                keys.set(key);
+            }
+            pool.close();
+
+            // Remove this pool if we know no more active objects will be 
returned.
+            synchronized (objectPools) {
+                if (pool.getNumActive() == 0) {
+                    objectPools.remove(key);
+                    pool.close();
+                }
+            }
+        } catch (Exception e) {
+            // swallowed
+            // XXX: In pool 3 this catch block will not be necessary and 
shouled be removed
+        } finally {
+            if (keys != null) {
+                keys.set(null); // unset key
             }
         }
     }

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=388382&r1=388381&r2=388382&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
 Thu Mar 23 21:30:41 2006
@@ -165,10 +165,8 @@
     }
 
     /**
-     * Create an object using my [EMAIL PROTECTED] #setFactory factory} or 
other
-     * implementation dependent mechanism, and place it into the pool.
-     * addObject() is useful for "pre-loading" a pool with idle objects.
-     * (Optional operation).
+     * Create an object using the [EMAIL PROTECTED] #setFactory factory} and 
place it into the pool.
+     * <code>addObject</code> is useful for "pre-loading" a pool with idle 
objects.
      *
      * @throws Exception if there is an unexpected problem.
      */
@@ -182,17 +180,16 @@
     }
 
     /**
-     * Obtain an instance from my pool.
-     * By contract, clients MUST return
-     * the borrowed instance using
-     * [EMAIL PROTECTED] #returnObject(Object) returnObject}
-     * or a related method as defined in an implementation
-     * or sub-interface.
-     * <p/>
-     * The behaviour of this method when the pool has been exhausted
-     * is not specified (although it may be specified by implementations).
+     * Obtain an instance from this pool. By contract, clients
+     * <strong>must</strong> return the borrowed instance using
+     * [EMAIL PROTECTED] #returnObject returnObject} or a related method as 
defined
+     * in an implementation or sub-interface.
+     * <p>
+     * The behaviour of this method when the pool has been exhausted will
+     * depend on the requested configuration.
+     * </p>
      *
-     * @return an instance from my pool.
+     * @return an instance from this pool.
      * @throws Exception if there is an unexpected problem.
      */
     public Object borrowObject() throws Exception {
@@ -205,7 +202,7 @@
      * Basicly just the [EMAIL PROTECTED] #borrowObject()} method that doesn't 
check if the pool has been [EMAIL PROTECTED] #close() closed}.
      * Needed by [EMAIL PROTECTED] #clear()}.
      *
-     * @return an instance from my pool.
+     * @return an instance from this pool.
      * @throws Exception if there is an unexpected problem.
      * @see #borrowObject()
      */
@@ -223,16 +220,14 @@
     }
 
     /**
-     * Return an instance to my pool.
-     * By contract, <i>obj</i> MUST have been obtained
-     * using [EMAIL PROTECTED] #borrowObject() borrowObject}
-     * or a related method as defined in an implementation
-     * or sub-interface.
+     * Return an instance to this pool. By contract, <code>obj</code>
+     * <strong>must</strong> have been obtained using
+     * [EMAIL PROTECTED] #borrowObject() borrowObject} or a related method as 
defined
+     * in an implementation or sub-interface.
      *
      * @param obj a [EMAIL PROTECTED] #borrowObject borrowed} instance to be 
returned.
-     * @throws Exception if there is an unexpected problem.
      */
-    public void returnObject(final Object obj) throws Exception {
+    public void returnObject(final Object obj) {
         if (validateOnReturn) {
             if (!factory.validateObject(obj)) {
                 invalidateObject(obj);
@@ -258,21 +253,21 @@
 
     /**
      * Invalidates an object from the pool
-     * By contract, <i>obj</i> MUST have been obtained
+     * By contract, <code>obj</code> <strong>must</strong> have been obtained
      * using [EMAIL PROTECTED] #borrowObject() borrowObject}
      * or a related method as defined in an implementation
      * or sub-interface.
-     * <p/>
+     * <p>
      * This method should be used when an object that has been borrowed
      * is determined (due to an exception or other problem) to be invalid.
      * If the connection should be validated before or after borrowing,
      * then the [EMAIL PROTECTED] PoolableObjectFactory#validateObject} method 
should be
      * used instead.
+     * </p>
      *
      * @param obj a [EMAIL PROTECTED] #borrowObject borrowed} instance to be 
returned.
-     * @throws Exception if there is an unexpected problem.
      */
-    public void invalidateObject(final Object obj) throws Exception {
+    public void invalidateObject(final Object obj) {
         synchronized (pool) {
             if (pool.contains(obj)) {
                 throw new IllegalStateException("An object currently in the 
pool cannot be invalidated.");
@@ -311,53 +306,50 @@
 
     /**
      * Close this pool, and free any resources associated with it.
-     *
-     * @throws Exception if there is an unexpected problem.
      */
-    public void close() throws Exception {
+    public void close() {
         open = false;
         Thread.yield(); // encourage any threads currently executing in the 
pool to finish first.
         synchronized (pool) {
-            clear();
+            try {
+                clear();
+            } catch (Exception e) {
+                // swallowed
+            }
             pool.notifyAll(); // Tell any WaitLimitManagers currently blocking 
to exit
         }
     }
 
     /**
-     * Sets the [EMAIL PROTECTED] PoolableObjectFactory factory} I use
-     * to create new instances (optional operation).
+     * Always throws <code>UnsupportedOperationException</code>.
      *
-     * @param factory the [EMAIL PROTECTED] PoolableObjectFactory} I use to 
create new instances.
-     * @throws IllegalStateException         when the factory cannot be set at 
this time
+     * @param factory the [EMAIL PROTECTED] PoolableObjectFactory} used to 
create new instances.
      * @throws UnsupportedOperationException if this implementation does not 
support the operation
      */
     public void setFactory(final PoolableObjectFactory factory) throws 
IllegalStateException, UnsupportedOperationException {
-        throw new UnsupportedOperationException("Replacing the factory not 
supported. Create a new pool instance instead.");
+        if (this.factory != factory) {
+            throw new UnsupportedOperationException("Replacing the factory not 
supported. Create a new pool instance instead.");
+        }
     }
 
     /**
-     * Return the number of instances
-     * currently borrowed from my pool
-     * (optional operation).
+     * Return the number of instances currently borrowed from this pool.
      *
-     * @return the number of instances currently borrowed in my pool
-     * @throws UnsupportedOperationException if this implementation does not 
support the operation
+     * @return the number of instances currently borrowed from this pool
      */
-    public int getNumActive() throws UnsupportedOperationException {
+    public int getNumActive() {
         return tracker.getBorrowed();
     }
 
     /**
-     * Return the number of instances
-     * currently idle in my pool (optional operation).
+     * Return the number of instances currently idle in this pool.
      * This may be considered an approximation of the number
      * of objects that can be [EMAIL PROTECTED] #borrowObject borrowed}
      * without creating any new instances.
      *
-     * @return the number of instances currently idle in my pool
-     * @throws UnsupportedOperationException if this implementation does not 
support the operation
+     * @return the number of instances currently idle in this pool
      */
-    public int getNumIdle() throws UnsupportedOperationException {
+    public int getNumIdle() {
         return lender.size();
     }
 

Modified: 
jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/DelegateManager.java
URL: 
http://svn.apache.org/viewcvs/jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/DelegateManager.java?rev=388382&r1=388381&r2=388382&view=diff
==============================================================================
--- 
jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/DelegateManager.java
 (original)
+++ 
jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/DelegateManager.java
 Thu Mar 23 21:30:41 2006
@@ -79,9 +79,8 @@
      * Delegates to another [EMAIL PROTECTED] Manager}.
      *
      * @param obj the object to return to the pool.
-     * @throws Exception as thrown by [EMAIL PROTECTED] 
PoolableObjectFactory#passivateObject(Object)}.
      */
-    public void returnToPool(final Object obj) throws Exception {
+    public void returnToPool(final Object obj) {
         delegate.returnToPool(obj);
     }
 

Modified: 
jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/IdleLimitManager.java
URL: 
http://svn.apache.org/viewcvs/jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/IdleLimitManager.java?rev=388382&r1=388381&r2=388382&view=diff
==============================================================================
--- 
jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/IdleLimitManager.java
 (original)
+++ 
jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/IdleLimitManager.java
 Thu Mar 23 21:30:41 2006
@@ -46,9 +46,8 @@
      * Possible remove an idle object and delegates to another [EMAIL 
PROTECTED] Manager}.
      *
      * @param obj the object to return to the pool.
-     * @throws Exception as thrown by [EMAIL PROTECTED] 
PoolableObjectFactory#passivateObject(Object)}.
      */
-    public void returnToPool(final Object obj) throws Exception {
+    public void returnToPool(final Object obj) {
         assert Thread.holdsLock(objectPool.getPool());
         if (maxIdle > 0 && maxIdle <= objectPool.getNumIdle()) {
             // XXX Does this remove the most stale object in

Modified: 
jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/KeyedPoolableObjectFactoryAdapter.java
URL: 
http://svn.apache.org/viewcvs/jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/KeyedPoolableObjectFactoryAdapter.java?rev=388382&r1=388381&r2=388382&view=diff
==============================================================================
--- 
jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/KeyedPoolableObjectFactoryAdapter.java
 (original)
+++ 
jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/KeyedPoolableObjectFactoryAdapter.java
 Thu Mar 23 21:30:41 2006
@@ -88,10 +88,10 @@
 
     /**
      * Ensures that the instance is safe to be returned by the pool.
-     * Returns <tt>false</tt> if this object should be destroyed.
+     * Returns <code>false</code> if this object should be destroyed.
      * @param obj the instance to be validated
-     * @return <tt>false</tt> if this <i>obj</i> is not valid and should
-     *         be dropped from the pool, <tt>true</tt> otherwise.
+     * @return <code>false</code> if this <code>obj</code> is not valid and 
should
+     *         be dropped from the pool, <code>true</code> otherwise.
      */
     public boolean validateObject(final Object obj) {
         return delegate.validateObject(keys.get(), obj);

Modified: 
jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/Manager.java
URL: 
http://svn.apache.org/viewcvs/jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/Manager.java?rev=388382&r1=388381&r2=388382&view=diff
==============================================================================
--- 
jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/Manager.java
 (original)
+++ 
jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/Manager.java
 Thu Mar 23 21:30:41 2006
@@ -58,7 +58,6 @@
      * Return an object to the pool. Object will be [EMAIL PROTECTED] 
PoolableObjectFactory#passivateObject(Object) passivated}.
      *
      * @param obj the object to return to the pool.
-     * @throws Exception as thrown by [EMAIL PROTECTED] 
PoolableObjectFactory#passivateObject(Object)}.
      */
-    public void returnToPool(Object obj) throws Exception;
+    public void returnToPool(Object obj);
 }

Modified: 
jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/NullTracker.java
URL: 
http://svn.apache.org/viewcvs/jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/NullTracker.java?rev=388382&r1=388381&r2=388382&view=diff
==============================================================================
--- 
jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/NullTracker.java
 (original)
+++ 
jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/NullTracker.java
 Thu Mar 23 21:30:41 2006
@@ -47,13 +47,12 @@
     }
 
     /**
-     * Throws [EMAIL PROTECTED] UnsupportedOperationException}.
+     * Unsupported, returns a negative value.
      * 
-     * @return doesn't, always throws an [EMAIL PROTECTED] 
UnsupportedOperationException}.
-     * @throws UnsupportedOperationException
+     * @return a negative value.
      */
     public int getBorrowed() {
-        throw new UnsupportedOperationException("tracking disabled");
+        return -1;
     }
 
     public String toString() {

Modified: 
jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/Tracker.java
URL: 
http://svn.apache.org/viewcvs/jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/Tracker.java?rev=388382&r1=388381&r2=388382&view=diff
==============================================================================
--- 
jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/Tracker.java
 (original)
+++ 
jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/Tracker.java
 Thu Mar 23 21:30:41 2006
@@ -58,7 +58,7 @@
     /**
      * The number of "borrowed" or active objects from the pool.
      *
-     * @return the number of "borrowed" active objects.
+     * @return the number of "borrowed" active objects or negative if 
unsupported.
      */
     public int getBorrowed();
 }

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=388382&r1=388381&r2=388382&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
 Thu Mar 23 21:30:41 2006
@@ -19,6 +19,7 @@
 import junit.framework.TestCase;
 import org.apache.commons.pool.BasePoolableObjectFactory;
 import org.apache.commons.pool.PoolableObjectFactory;
+import org.apache.commons.pool.TestObjectPool;
 
 import java.util.NoSuchElementException;
 import java.util.SortedSet;
@@ -37,10 +38,10 @@
 public class TestCompositeObjectPool extends TestCase {
     private CompositeObjectPool pool = null;
 
-    protected void setUp() throws Exception {
+    public void setUp() throws Exception {
     }
 
-    protected void tearDown() throws Exception {
+    public void tearDown() throws Exception {
         if (pool != null) {
             pool.close();
             pool = null;
@@ -258,21 +259,15 @@
      */
     public void testNullTracker() throws Exception {
         pool = new CompositeObjectPool(new IntegerFactory(), new 
GrowManager(), new FifoLender(), new NullTracker(), false);
-        try {
-            pool.getNumActive();
-            fail("Should have thrown an UnsupportedOperationException.");
-        } catch(UnsupportedOperationException usoee) {
-            // expected
-        }
+        assertTrue("Expected negative value.", pool.getNumActive() < 0);
 
-        Integer zero = (Integer)pool.borrowObject();
+        final Integer zero = (Integer)pool.borrowObject();
 
-        try {
-            pool.getNumActive();
-            fail("Should have thrown an UnsupportedOperationException.");
-        } catch(UnsupportedOperationException usoee) {
-            // expected
-        }
+        assertTrue("Expected negative value.", pool.getNumActive() < 0);
+
+        pool.returnObject(zero);
+
+        assertTrue("Expected negative value.", pool.getNumActive() < 0);
     }
 
     /**



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to