You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ma...@apache.org on 2014/01/30 15:42:59 UTC
svn commit: r1562841 - in /commons/proper/pool/branches/1_5_RELEASE/src:
changes/changes.xml
java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java
java/org/apache/commons/pool/impl/GenericObjectPool.java
Author: markt
Date: Thu Jan 30 14:42:58 2014
New Revision: 1562841
URL: http://svn.apache.org/r1562841
Log:
Better exception handling. Found while working on a DBCP issue.
Modified:
commons/proper/pool/branches/1_5_RELEASE/src/changes/changes.xml
commons/proper/pool/branches/1_5_RELEASE/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java
commons/proper/pool/branches/1_5_RELEASE/src/java/org/apache/commons/pool/impl/GenericObjectPool.java
Modified: commons/proper/pool/branches/1_5_RELEASE/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/pool/branches/1_5_RELEASE/src/changes/changes.xml?rev=1562841&r1=1562840&r2=1562841&view=diff
==============================================================================
--- commons/proper/pool/branches/1_5_RELEASE/src/changes/changes.xml (original)
+++ commons/proper/pool/branches/1_5_RELEASE/src/changes/changes.xml Thu Jan 30 14:42:58 2014
@@ -30,6 +30,11 @@
not create minIdle instances only to have them immediately destroyed by
using maxIdle for minIdle in this case.
</action>
+ <action dev="markt" type="fix">
+ Do not swallow original exception and stack trace when borrowObject()
+ fails because the object factory is unable to validate the newly created
+ object.
+ </action>
</release>
<release version="1.5.7" date="2011-12-20" description="This is a patch release, including bugfixes only.">
<action dev="psteitz" type="fix" issue="POOL-189" due-to="Bill Speirs">
Modified: commons/proper/pool/branches/1_5_RELEASE/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/branches/1_5_RELEASE/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java?rev=1562841&r1=1562840&r2=1562841&view=diff
==============================================================================
--- commons/proper/pool/branches/1_5_RELEASE/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java (original)
+++ commons/proper/pool/branches/1_5_RELEASE/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java Thu Jan 30 14:42:58 2014
@@ -358,7 +358,7 @@ public class GenericKeyedObjectPool exte
* @see #setFactory(KeyedPoolableObjectFactory)
*/
public GenericKeyedObjectPool() {
- this(null, DEFAULT_MAX_ACTIVE, DEFAULT_WHEN_EXHAUSTED_ACTION, DEFAULT_MAX_WAIT, DEFAULT_MAX_IDLE,
+ this(null, DEFAULT_MAX_ACTIVE, DEFAULT_WHEN_EXHAUSTED_ACTION, DEFAULT_MAX_WAIT, DEFAULT_MAX_IDLE,
DEFAULT_TEST_ON_BORROW, DEFAULT_TEST_ON_RETURN, DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,
DEFAULT_NUM_TESTS_PER_EVICTION_RUN, DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS, DEFAULT_TEST_WHILE_IDLE);
}
@@ -394,7 +394,7 @@ public class GenericKeyedObjectPool exte
*/
public GenericKeyedObjectPool(KeyedPoolableObjectFactory factory, int maxActive) {
this(factory,maxActive, DEFAULT_WHEN_EXHAUSTED_ACTION, DEFAULT_MAX_WAIT, DEFAULT_MAX_IDLE,
- DEFAULT_TEST_ON_BORROW, DEFAULT_TEST_ON_RETURN, DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,
+ DEFAULT_TEST_ON_BORROW, DEFAULT_TEST_ON_RETURN, DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,
DEFAULT_NUM_TESTS_PER_EVICTION_RUN, DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS, DEFAULT_TEST_WHILE_IDLE);
}
@@ -480,7 +480,7 @@ public class GenericKeyedObjectPool exte
* if not <code>null</code>
* @param maxActive the maximum number of objects that can be borrowed from me at one time
* (see {@link #setMaxActive})
- * @param whenExhaustedAction the action to take when the pool is exhausted
+ * @param whenExhaustedAction the action to take when the pool is exhausted
* (see {@link #setWhenExhaustedAction})
* @param maxWait the maximum amount of time to wait for an idle object when the pool is exhausted and
* <code>whenExhaustedAction</code> is {@link #WHEN_EXHAUSTED_BLOCK} (otherwise ignored) (see {@link #setMaxWait})
@@ -815,7 +815,7 @@ public class GenericKeyedObjectPool exte
* <p>
* If the configured value of minIdle is greater than the configured value
* for maxIdle then the value of maxIdle will be used instead.
- *
+ *
* @param poolSize - The minimum size of the each keyed pool
* @since Pool 1.3
* @see #getMinIdle
@@ -834,7 +834,7 @@ public class GenericKeyedObjectPool exte
* <p>
* If the configured value of minIdle is greater than the configured value
* for maxIdle then the value of maxIdle will be used instead.
- *
+ *
* @return minimum size of the each keyed pool
* @since Pool 1.3
* @see #setTimeBetweenEvictionRunsMillis
@@ -947,7 +947,7 @@ public class GenericKeyedObjectPool exte
* Sets the max number of objects to examine during each run of the
* idle object evictor thread (if any).
* <p>
- * When a negative value is supplied,
+ * When a negative value is supplied,
* <code>ceil({@link #getNumIdle()})/abs({@link #getNumTestsPerEvictionRun})</code>
* tests will be run. I.e., when the value is <code>-n</code>, roughly one <code>n</code>th of the
* idle objects will be tested per run. When the value is positive, the number of tests
@@ -1071,31 +1071,31 @@ public class GenericKeyedObjectPool exte
/**
* <p>Borrows an object from the keyed pool associated with the given key.</p>
- *
+ *
* <p>If there is an idle instance available in the pool associated with the given key, then
* either the most-recently returned (if {@link #getLifo() lifo} == true) or "oldest" (lifo == false)
* instance sitting idle in the pool will be activated and returned. If activation fails, or
* {@link #getTestOnBorrow() testOnBorrow} is set to true and validation fails, the instance is destroyed and the
* next available instance is examined. This continues until either a valid instance is returned or there
* are no more idle instances available.</p>
- *
+ *
* <p>If there are no idle instances available in the pool associated with the given key, behavior
* depends on the {@link #getMaxActive() maxActive}, {@link #getMaxTotal() maxTotal}, and (if applicable)
* {@link #getWhenExhaustedAction() whenExhaustedAction} and {@link #getMaxWait() maxWait} properties. If the
* number of instances checked out from the pool under the given key is less than <code>maxActive</code> and
* the total number of instances in circulation (under all keys) is less than <code>maxTotal</code>, a new instance
* is created, activated and (if applicable) validated and returned to the caller.</p>
- *
+ *
* <p>If the associated keyed pool is exhausted (no available idle instances and no capacity to create new ones),
* this method will either block ({@link #WHEN_EXHAUSTED_BLOCK}), throw a <code>NoSuchElementException</code>
* ({@link #WHEN_EXHAUSTED_FAIL}), or grow ({@link #WHEN_EXHAUSTED_GROW} - ignoring maxActive, maxTotal properties).
* The length of time that this method will block when <code>whenExhaustedAction == WHEN_EXHAUSTED_BLOCK</code>
* is determined by the {@link #getMaxWait() maxWait} property.</p>
- *
+ *
* <p>When the pool is exhausted, multiple calling threads may be simultaneously blocked waiting for instances
* to become available. As of pool 1.5, a "fairness" algorithm has been implemented to ensure that threads receive
* available instances in request arrival order.</p>
- *
+ *
* @param key pool key
* @return object instance from the keyed pool
* @throws NoSuchElementException if a keyed object instance cannot be returned.
@@ -1272,9 +1272,10 @@ public class GenericKeyedObjectPool exte
}
allocate();
if (newlyCreated) {
- throw new NoSuchElementException(
- "Could not create a validated object, cause: " +
- e.getMessage());
+ NoSuchElementException nsee = new NoSuchElementException(
+ "Unable to validate object");
+ nsee.initCause(e);
+ throw nsee;
}
else {
continue; // keep looping
@@ -1294,9 +1295,9 @@ public class GenericKeyedObjectPool exte
synchronized (this) {
if (isClosed()) return;
-
+
Iterator allocationQueueIter = _allocationQueue.iterator();
-
+
while (allocationQueueIter.hasNext()) {
// First use any objects in the pool to clear the queue
Latch latch = (Latch) allocationQueueIter.next();
@@ -1350,7 +1351,7 @@ public class GenericKeyedObjectPool exte
}
}
}
-
+
if (clearOldest) {
/* Clear oldest calls factory methods so it must be called from
* outside the sync block.
@@ -1363,13 +1364,13 @@ public class GenericKeyedObjectPool exte
clearOldest();
}
}
-
+
/**
* Clears any objects sitting idle in the pool by removing them from the
* idle instance pool and then invoking the configured PoolableObjectFactory's
* {@link KeyedPoolableObjectFactory#destroyObject(Object, Object)} method on
* each idle instance.
- *
+ *
* <p> Implementation notes:
* <ul><li>This method does not destroy or effect in any way instances that are
* checked out when it is invoked.</li>
@@ -1404,7 +1405,7 @@ public class GenericKeyedObjectPool exte
/**
* Clears oldest 15% of objects in pool. The method sorts the
* objects into a TreeMap and then iterates the first 15% for removal.
- *
+ *
* @since Pool 1.3
*/
public void clearOldest() {
@@ -1489,7 +1490,7 @@ public class GenericKeyedObjectPool exte
/**
* Assuming Map<Object,Collection<ObjectTimestampPair>>, destroy all
* ObjectTimestampPair.value using the supplied factory.
- *
+ *
* @param m Map containing keyed pools to clear
* @param factory KeyedPoolableObjectFactory used to destroy the objects
*/
@@ -1570,18 +1571,18 @@ public class GenericKeyedObjectPool exte
/**
* <p>Returns an object to a keyed pool.</p>
- *
+ *
* <p>For the pool to function correctly, the object instance <strong>must</strong> have been borrowed
* from the pool (under the same key) and not yet returned. Repeated <code>returnObject</code> calls on
* the same object/key pair (with no <code>borrowObject</code> calls in between) will result in multiple
* references to the object in the idle instance pool.</p>
- *
+ *
* <p>If {@link #getMaxIdle() maxIdle} is set to a positive value and the number of idle instances under the given
* key has reached this value, the returning instance is destroyed.</p>
- *
+ *
* <p>If {@link #getTestOnReturn() testOnReturn} == true, the returning instance is validated before being returned
* to the idle instance pool under the given key. In this case, if validation fails, the instance is destroyed.</p>
- *
+ *
* @param key pool key
* @param obj instance to return to the keyed pool
* @throws Exception
@@ -1618,13 +1619,13 @@ public class GenericKeyedObjectPool exte
/**
* <p>Adds an object to the keyed pool.</p>
- *
+ *
* <p>Validates the object if testOnReturn == true and passivates it before returning it to the pool.
* if validation or passivation fails, or maxIdle is set and there is no room in the pool, the instance
* is destroyed.</p>
- *
+ *
* <p>Calls {@link #allocate()} on successful completion</p>
- *
+ *
* @param key pool key
* @param obj instance to add to the keyed pool
* @param decrementNumActive whether or not to decrement the active count associated with the keyed pool
@@ -1708,9 +1709,9 @@ public class GenericKeyedObjectPool exte
/**
* {@inheritDoc}
- * <p>Activation of this method decrements the active count associated with the given keyed pool
+ * <p>Activation of this method decrements the active count associated with the given keyed pool
* and attempts to destroy <code>obj.</code></p>
- *
+ *
* @param key pool key
* @param obj instance to invalidate
* @throws Exception if an exception occurs destroying the object
@@ -1797,9 +1798,9 @@ public class GenericKeyedObjectPool exte
* will fail with IllegalStateException, but {@link #returnObject(Object, Object)} and
* {@link #invalidateObject(Object, Object)} will continue to work, with returned objects
* destroyed on return.</p>
- *
- * <p>Destroys idle instances in the pool by invoking {@link #clear()}.</p>
- *
+ *
+ * <p>Destroys idle instances in the pool by invoking {@link #clear()}.</p>
+ *
* @throws Exception
*/
public void close() throws Exception {
@@ -1815,10 +1816,10 @@ public class GenericKeyedObjectPool exte
_evictionKeyCursor = null;
}
startEvictor(-1L);
-
+
while(_allocationQueue.size() > 0) {
Latch l = (Latch) _allocationQueue.removeFirst();
-
+
synchronized (l) {
// notify the waiting thread
l.notify();
@@ -1829,11 +1830,11 @@ public class GenericKeyedObjectPool exte
/**
* <p>Sets the keyed poolable object factory associated with this pool.</p>
- *
+ *
* <p>If this method is called when objects are checked out of any of the keyed pools,
* an IllegalStateException is thrown. Calling this method also has the side effect of
* destroying any idle instances in existing keyed pools, using the original factory.</p>
- *
+ *
* @param factory KeyedPoolableObjectFactory to use when creating keyed object pool instances
* @throws IllegalStateException if there are active (checked out) instances associated with this keyed object pool
* @deprecated to be removed in version 2.0
@@ -2157,7 +2158,7 @@ public class GenericKeyedObjectPool exte
/**
* Returns pool info including {@link #getNumActive()}, {@link #getNumIdle()}
* and currently defined keys.
- *
+ *
* @return string containing debug information
*/
synchronized String debugInfo() {
@@ -2172,11 +2173,11 @@ public class GenericKeyedObjectPool exte
return buf.toString();
}
- /**
+ /**
* Returns the number of tests to be performed in an Evictor run,
* based on the current values of <code>_numTestsPerEvictionRun</code>
* and <code>_totalIdle</code>.
- *
+ *
* @see #setNumTestsPerEvictionRun
* @return the number of tests for the Evictor to run
*/
@@ -2192,7 +2193,7 @@ public class GenericKeyedObjectPool exte
* This returns the number of objects to create during the pool
* sustain cycle. This will ensure that the minimum number of idle
* instances is maintained without going past the maxActive value.
- *
+ *
* @param pool the ObjectPool to calculate the deficit for
* @param incrementInternal - Should the count of objects currently under
* some form of internal processing be
@@ -2231,10 +2232,10 @@ public class GenericKeyedObjectPool exte
private class ObjectQueue {
/** Number of instances checked out to clients from this queue */
private int activeCount = 0;
-
+
/** Idle instance queue */
private final CursorableLinkedList queue = new CursorableLinkedList();
-
+
/** Number of instances in process of being created */
private int internalProcessingCount = 0;
@@ -2282,12 +2283,12 @@ public class GenericKeyedObjectPool exte
*/
static class ObjectTimestampPair implements Comparable {
//CHECKSTYLE: stop VisibilityModifier
- /**
- * Object instance
+ /**
+ * Object instance
* @deprecated this field will be made private and final in version 2.0
*/
Object value;
-
+
/**
* timestamp
* @deprecated this field will be made private and final in version 2.0
@@ -2315,7 +2316,7 @@ public class GenericKeyedObjectPool exte
/**
* Returns a string representation.
- *
+ *
* @return String representing this ObjectTimestampPair
*/
public String toString() {
@@ -2325,7 +2326,7 @@ public class GenericKeyedObjectPool exte
/**
* Compares this to another object by casting the argument to an
* ObjectTimestampPair.
- *
+ *
* @param obj object to cmpare
* @return result of comparison
*/
@@ -2336,7 +2337,7 @@ public class GenericKeyedObjectPool exte
/**
* Compares this to another ObjectTimestampPair, using the timestamp as basis for comparison.
* Implementation is consistent with equals.
- *
+ *
* @param other object to compare
* @return result of comparison
*/
@@ -2475,20 +2476,20 @@ public class GenericKeyedObjectPool exte
* Latch used to control allocation order of objects to threads to ensure
* fairness. That is, for each key, objects are allocated to threads in the order
* that threads request objects.
- *
+ *
* @since 1.5
*/
private static final class Latch {
-
+
/** key of associated pool */
private final Object _key;
-
+
/** keyed pool associated with this latch */
private ObjectQueue _pool;
-
+
/** holds an ObjectTimestampPair when this latch has been allocated an instance */
private ObjectTimestampPair _pair;
-
+
/** indicates that this latch can create an instance */
private boolean _mayCreate = false;
@@ -2515,7 +2516,7 @@ public class GenericKeyedObjectPool exte
private synchronized ObjectQueue getPool() {
return _pool;
}
-
+
/**
* Sets the pool associated with this latch
* @param pool the pool
@@ -2526,13 +2527,13 @@ public class GenericKeyedObjectPool exte
/**
* Gets the ObjectTimestampPair allocated to this latch.
- * Returns null if this latch does not have an instance allocated to it.
+ * Returns null if this latch does not have an instance allocated to it.
* @return the associated ObjectTimestampPair
*/
private synchronized ObjectTimestampPair getPair() {
return _pair;
}
-
+
/**
* Allocate an ObjectTimestampPair to this latch.
* @param pair ObjectTimestampPair on this latch
@@ -2548,10 +2549,10 @@ public class GenericKeyedObjectPool exte
private synchronized boolean mayCreate() {
return _mayCreate;
}
-
+
/**
* Sets the mayCreate property
- *
+ *
* @param mayCreate true means this latch can create an instance
*/
private synchronized void setMayCreate(boolean mayCreate) {
@@ -2747,7 +2748,7 @@ public class GenericKeyedObjectPool exte
/** Eviction cursor (over instances within-key) */
private CursorableLinkedList.Cursor _evictionCursor = null;
-
+
/** Eviction cursor (over keys) */
private CursorableLinkedList.Cursor _evictionKeyCursor = null;
Modified: commons/proper/pool/branches/1_5_RELEASE/src/java/org/apache/commons/pool/impl/GenericObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/branches/1_5_RELEASE/src/java/org/apache/commons/pool/impl/GenericObjectPool.java?rev=1562841&r1=1562840&r2=1562841&view=diff
==============================================================================
--- commons/proper/pool/branches/1_5_RELEASE/src/java/org/apache/commons/pool/impl/GenericObjectPool.java (original)
+++ commons/proper/pool/branches/1_5_RELEASE/src/java/org/apache/commons/pool/impl/GenericObjectPool.java Thu Jan 30 14:42:58 2014
@@ -361,8 +361,8 @@ public class GenericObjectPool extends B
*/
public GenericObjectPool(PoolableObjectFactory factory, GenericObjectPool.Config config) {
this(factory, config.maxActive, config.whenExhaustedAction, config.maxWait, config.maxIdle, config.minIdle,
- config.testOnBorrow, config.testOnReturn, config.timeBetweenEvictionRunsMillis,
- config.numTestsPerEvictionRun, config.minEvictableIdleTimeMillis, config.testWhileIdle,
+ config.testOnBorrow, config.testOnReturn, config.timeBetweenEvictionRunsMillis,
+ config.numTestsPerEvictionRun, config.minEvictableIdleTimeMillis, config.testWhileIdle,
config.softMinEvictableIdleTimeMillis, config.lifo);
}
@@ -415,7 +415,7 @@ public class GenericObjectPool extends B
* @param factory the (possibly <tt>null</tt>)PoolableObjectFactory to use to create, validate and destroy objects
* @param maxActive the maximum number of objects that can be borrowed at one time (see {@link #setMaxActive})
* @param whenExhaustedAction the action to take when the pool is exhausted (see {@link #getWhenExhaustedAction})
- * @param maxWait the maximum amount of time to wait for an idle object when the pool is exhausted and
+ * @param maxWait the maximum amount of time to wait for an idle object when the pool is exhausted and
* <i>whenExhaustedAction</i> is {@link #WHEN_EXHAUSTED_BLOCK} (otherwise ignored) (see {@link #getMaxWait})
* @param maxIdle the maximum number of idle objects in my pool (see {@link #getMaxIdle})
*/
@@ -450,7 +450,7 @@ public class GenericObjectPool extends B
* @param factory the (possibly <tt>null</tt>)PoolableObjectFactory to use to create, validate and destroy objects
* @param maxActive the maximum number of objects that can be borrowed at one time (see {@link #setMaxActive})
* @param whenExhaustedAction the action to take when the pool is exhausted (see {@link #setWhenExhaustedAction})
- * @param maxWait the maximum amount of time to wait for an idle object when the pool is exhausted and
+ * @param maxWait the maximum amount of time to wait for an idle object when the pool is exhausted and
* <i>whenExhaustedAction</i> is {@link #WHEN_EXHAUSTED_BLOCK} (otherwise ignored) (see {@link #setMaxWait})
* @param maxIdle the maximum number of idle objects in my pool (see {@link #setMaxIdle})
* @param testOnBorrow whether or not to validate objects before they are returned by the {@link #borrowObject}
@@ -1039,28 +1039,28 @@ public class GenericObjectPool extends B
/**
* <p>Borrows an object from the pool.</p>
- *
+ *
* <p>If there is an idle instance available in the pool, then either the most-recently returned
* (if {@link #getLifo() lifo} == true) or "oldest" (lifo == false) instance sitting idle in the pool
* will be activated and returned. If activation fails, or {@link #getTestOnBorrow() testOnBorrow} is set
* to true and validation fails, the instance is destroyed and the next available instance is examined.
* This continues until either a valid instance is returned or there are no more idle instances available.</p>
- *
+ *
* <p>If there are no idle instances available in the pool, behavior depends on the {@link #getMaxActive() maxActive}
* and (if applicable) {@link #getWhenExhaustedAction() whenExhaustedAction} and {@link #getMaxWait() maxWait}
* properties. If the number of instances checked out from the pool is less than <code>maxActive,</code> a new
* instance is created, activated and (if applicable) validated and returned to the caller.</p>
- *
+ *
* <p>If the pool is exhausted (no available idle instances and no capacity to create new ones),
* this method will either block ({@link #WHEN_EXHAUSTED_BLOCK}), throw a <code>NoSuchElementException</code>
* ({@link #WHEN_EXHAUSTED_FAIL}), or grow ({@link #WHEN_EXHAUSTED_GROW} - ignoring maxActive).
* The length of time that this method will block when <code>whenExhaustedAction == WHEN_EXHAUSTED_BLOCK</code>
* is determined by the {@link #getMaxWait() maxWait} property.</p>
- *
+ *
* <p>When the pool is exhausted, multiple calling threads may be simultaneously blocked waiting for instances
* to become available. As of pool 1.5, a "fairness" algorithm has been implemented to ensure that threads receive
* available instances in request arrival order.</p>
- *
+ *
* @return object instance
* @throws NoSuchElementException if an instance cannot be returned
*/
@@ -1239,7 +1239,10 @@ public class GenericObjectPool extends B
}
allocate();
if(newlyCreated) {
- throw new NoSuchElementException("Could not create a validated object, cause: " + e.getMessage());
+ NoSuchElementException nsee = new NoSuchElementException(
+ "Could not create a validated object");
+ nsee.initCause(e);
+ throw nsee;
}
else {
continue; // keep looping
@@ -1252,7 +1255,7 @@ public class GenericObjectPool extends B
* Allocate available instances to latches in the allocation queue. Then
* set _mayCreate to true for as many additional latches remaining in queue
* as _maxActive allows. While it is safe for GOP, for consistency with GKOP
- * this method should not be called from inside a sync block.
+ * this method should not be called from inside a sync block.
*/
private synchronized void allocate() {
if (isClosed()) return;
@@ -1289,7 +1292,7 @@ public class GenericObjectPool extends B
/**
* {@inheritDoc}
* <p>Activation of this method decrements the active count and attempts to destroy the instance.</p>
- *
+ *
* @throws Exception if the configured {@link PoolableObjectFactory} throws an exception destroying obj
*/
public void invalidateObject(Object obj) throws Exception {
@@ -1307,10 +1310,10 @@ public class GenericObjectPool extends B
/**
* Clears any objects sitting idle in the pool by removing them from the
- * idle instance pool and then invoking the configured
+ * idle instance pool and then invoking the configured
* {@link PoolableObjectFactory#destroyObject(Object)} method on each idle
- * instance.
- *
+ * instance.
+ *
* <p> Implementation notes:
* <ul><li>This method does not destroy or effect in any way instances that are
* checked out of the pool when it is invoked.</li>
@@ -1332,11 +1335,11 @@ public class GenericObjectPool extends B
}
/**
- * Private method to destroy all the objects in a collection using the
+ * Private method to destroy all the objects in a collection using the
* supplied object factory. Assumes that objects in the collection are
* instances of ObjectTimestampPair and that the object instances that
* they wrap were created by the factory.
- *
+ *
* @param c Collection of objects to destroy
* @param factory PoolableConnectionFactory used to destroy the objects
*/
@@ -1375,13 +1378,13 @@ public class GenericObjectPool extends B
/**
* <p>Returns an object instance to the pool.</p>
- *
+ *
* <p>If {@link #getMaxIdle() maxIdle} is set to a positive value and the number of idle instances
* has reached this value, the returning instance is destroyed.</p>
- *
+ *
* <p>If {@link #getTestOnReturn() testOnReturn} == true, the returning instance is validated before being returned
* to the idle instance pool. In this case, if validation fails, the instance is destroyed.</p>
- *
+ *
* <p><strong>Note: </strong> There is no guard to prevent an object
* being returned to the pool multiple times. Clients are expected to
* discard references to returned objects and ensure that an object is not
@@ -1389,7 +1392,7 @@ public class GenericObjectPool extends B
* borrowed again between returns). Violating this contract will result in
* the same object appearing multiple times in the pool and pool counters
* (numActive, numIdle) returning incorrect values.</p>
- *
+ *
* @param obj instance to return to the pool
*/
public void returnObject(Object obj) throws Exception {
@@ -1415,13 +1418,13 @@ public class GenericObjectPool extends B
/**
* <p>Adds an object to the pool.</p>
- *
+ *
* <p>Validates the object if testOnReturn == true and passivates it before returning it to the pool.
* if validation or passivation fails, or maxIdle is set and there is no room in the pool, the instance
* is destroyed.</p>
- *
+ *
* <p>Calls {@link #allocate()} on successful completion</p>
- *
+ *
* @param obj instance to add to the pool
* @param decrementNumActive whether or not to decrement the active count
* @throws Exception
@@ -1487,9 +1490,9 @@ public class GenericObjectPool extends B
* will fail with IllegalStateException, but {@link #returnObject(Object)} and
* {@link #invalidateObject(Object)} will continue to work, with returned objects
* destroyed on return.</p>
- *
- * <p>Destroys idle instances in the pool by invoking {@link #clear()}.</p>
- *
+ *
+ * <p>Destroys idle instances in the pool by invoking {@link #clear()}.</p>
+ *
* @throws Exception
*/
public void close() throws Exception {
@@ -1500,7 +1503,7 @@ public class GenericObjectPool extends B
while(_allocationQueue.size() > 0) {
Latch l = (Latch) _allocationQueue.removeFirst();
-
+
synchronized (l) {
// notify the waiting thread
l.notify();
@@ -1537,7 +1540,7 @@ public class GenericObjectPool extends B
// save the current CCL to be used later by the evictor Thread
_factoryClassLoader = Thread.currentThread().getContextClassLoader();
}
- destroy(toDestroy, oldFactory);
+ destroy(toDestroy, oldFactory);
}
/**
@@ -1727,7 +1730,7 @@ public class GenericObjectPool extends B
/**
* Returns pool info including {@link #getNumActive()}, {@link #getNumIdle()}
* and a list of objects idle in the pool with their idle times.
- *
+ *
* @return string containing debug information
*/
synchronized String debugInfo() {
@@ -1744,11 +1747,11 @@ public class GenericObjectPool extends B
return buf.toString();
}
- /**
+ /**
* Returns the number of tests to be performed in an Evictor run,
* based on the current value of <code>numTestsPerEvictionRun</code>
* and the number of idle instances in the pool.
- *
+ *
* @see #setNumTestsPerEvictionRun
* @return the number of tests for the Evictor to run
*/
@@ -1871,10 +1874,10 @@ public class GenericObjectPool extends B
* threads request objects.
*/
private static final class Latch {
-
+
/** object timestamp pair allocated to this latch */
private ObjectTimestampPair _pair;
-
+
/** Whether or not this latch may create an object instance */
private boolean _mayCreate = false;
@@ -1885,7 +1888,7 @@ public class GenericObjectPool extends B
private synchronized ObjectTimestampPair getPair() {
return _pair;
}
-
+
/**
* Sets ObjectTimestampPair on this latch
* @param pair ObjectTimestampPair allocated to this latch
@@ -1895,13 +1898,13 @@ public class GenericObjectPool extends B
}
/**
- * Whether or not this latch may create an object instance
+ * Whether or not this latch may create an object instance
* @return true if this latch has an instance creation permit
*/
private synchronized boolean mayCreate() {
return _mayCreate;
}
-
+
/**
* Sets the mayCreate property
* @param mayCreate new value for mayCreate