diff --git a/src/main/java/org/apache/commons/pool2/BaseKeyedPooledObjectFactory.java b/src/main/java/org/apache/commons/pool2/BaseKeyedPooledObjectFactory.java
index b375ce2d0..a1762c893 100644
--- a/src/main/java/org/apache/commons/pool2/BaseKeyedPooledObjectFactory.java
+++ b/src/main/java/org/apache/commons/pool2/BaseKeyedPooledObjectFactory.java
@@ -29,11 +29,11 @@
*
* @param The type of keys managed by this factory.
* @param Type of element managed by this factory.
+ * @param Type of exception thrown by this factory.
*
* @since 2.0
*/
-public abstract class BaseKeyedPooledObjectFactory extends BaseObject
- implements KeyedPooledObjectFactory {
+public abstract class BaseKeyedPooledObjectFactory extends BaseObject implements KeyedPooledObjectFactory {
/**
* Reinitialize an instance to be returned by the pool.
@@ -45,8 +45,7 @@ public abstract class BaseKeyedPooledObjectFactory extends BaseObject
* @param p a {@code PooledObject} wrapping the instance to be activated
*/
@Override
- public void activateObject(final K key, final PooledObject p)
- throws Exception {
+ public void activateObject(final K key, final PooledObject p) throws E {
// The default implementation is a no-op.
}
@@ -56,11 +55,10 @@ public void activateObject(final K key, final PooledObject p)
* @param key the key used when constructing the object
* @return an instance that can be served by the pool
*
- * @throws Exception if there is a problem creating a new instance,
+ * @throws E if there is a problem creating a new instance,
* this will be propagated to the code requesting an object.
*/
- public abstract V create(K key)
- throws Exception;
+ public abstract V create(K key) throws E;
/**
* Destroy an instance no longer needed by the pool.
@@ -72,13 +70,12 @@ public abstract V create(K key)
* @param p a {@code PooledObject} wrapping the instance to be destroyed
*/
@Override
- public void destroyObject(final K key, final PooledObject p)
- throws Exception {
+ public void destroyObject(final K key, final PooledObject p) throws E {
// The default implementation is a no-op.
}
@Override
- public PooledObject makeObject(final K key) throws Exception {
+ public PooledObject makeObject(final K key) throws E {
return wrap(create(key));
}
@@ -92,8 +89,7 @@ public PooledObject makeObject(final K key) throws Exception {
* @param p a {@code PooledObject} wrapping the instance to be passivated
*/
@Override
- public void passivateObject(final K key, final PooledObject p)
- throws Exception {
+ public void passivateObject(final K key, final PooledObject p) throws E {
// The default implementation is a no-op.
}
diff --git a/src/main/java/org/apache/commons/pool2/BaseObjectPool.java b/src/main/java/org/apache/commons/pool2/BaseObjectPool.java
index 53c7deb23..62b94d4b8 100644
--- a/src/main/java/org/apache/commons/pool2/BaseObjectPool.java
+++ b/src/main/java/org/apache/commons/pool2/BaseObjectPool.java
@@ -25,10 +25,11 @@
*
*
* @param Type of element pooled in this pool.
+ * @param Type of exception thrown by this pool.
*
* @since 2.0
*/
-public abstract class BaseObjectPool extends BaseObject implements ObjectPool {
+public abstract class BaseObjectPool extends BaseObject implements ObjectPool {
private volatile boolean closed;
@@ -40,7 +41,7 @@ public abstract class BaseObjectPool extends BaseObject implements ObjectPool
* method
*/
@Override
- public void addObject() throws Exception, UnsupportedOperationException {
+ public void addObject() throws E, UnsupportedOperationException {
throw new UnsupportedOperationException();
}
@@ -59,7 +60,7 @@ protected final void assertOpen() throws IllegalStateException {
}
@Override
- public abstract T borrowObject() throws Exception;
+ public abstract T borrowObject() throws E;
/**
* Not supported in this base implementation.
@@ -68,7 +69,7 @@ protected final void assertOpen() throws IllegalStateException {
* method
*/
@Override
- public void clear() throws Exception, UnsupportedOperationException {
+ public void clear() throws E, UnsupportedOperationException {
throw new UnsupportedOperationException();
}
@@ -105,7 +106,7 @@ public int getNumIdle() {
}
@Override
- public abstract void invalidateObject(T obj) throws Exception;
+ public abstract void invalidateObject(T obj) throws E;
/**
* Has this pool instance been closed.
@@ -117,7 +118,7 @@ public final boolean isClosed() {
}
@Override
- public abstract void returnObject(T obj) throws Exception;
+ public abstract void returnObject(T obj) throws E;
@Override
protected void toStringAppendFields(final StringBuilder builder) {
diff --git a/src/main/java/org/apache/commons/pool2/BasePooledObjectFactory.java b/src/main/java/org/apache/commons/pool2/BasePooledObjectFactory.java
index 6302f1747..d7ae8de66 100644
--- a/src/main/java/org/apache/commons/pool2/BasePooledObjectFactory.java
+++ b/src/main/java/org/apache/commons/pool2/BasePooledObjectFactory.java
@@ -24,13 +24,14 @@
* This class is immutable, and therefore thread-safe
*
* @param Type of element managed in this factory.
+ * @param Type of exception thrown in this factory.
*
* @see PooledObjectFactory
* @see BaseKeyedPooledObjectFactory
*
* @since 2.0
*/
-public abstract class BasePooledObjectFactory extends BaseObject implements PooledObjectFactory {
+public abstract class BasePooledObjectFactory extends BaseObject implements PooledObjectFactory {
/**
* No-op.
@@ -38,7 +39,7 @@ public abstract class BasePooledObjectFactory extends BaseObject implements P
* @param p ignored
*/
@Override
- public void activateObject(final PooledObject p) throws Exception {
+ public void activateObject(final PooledObject p) throws E {
// The default implementation is a no-op.
}
@@ -49,10 +50,10 @@ public void activateObject(final PooledObject p) throws Exception {
*
* @return an instance to be served by the pool
*
- * @throws Exception if there is a problem creating a new instance,
+ * @throws E if there is a problem creating a new instance,
* this will be propagated to the code requesting an object.
*/
- public abstract T create() throws Exception;
+ public abstract T create() throws E;
/**
* No-op.
@@ -61,12 +62,12 @@ public void activateObject(final PooledObject p) throws Exception {
*/
@Override
public void destroyObject(final PooledObject p)
- throws Exception {
+ throws E {
// The default implementation is a no-op.
}
@Override
- public PooledObject makeObject() throws Exception {
+ public PooledObject makeObject() throws E {
return wrap(create());
}
@@ -77,7 +78,7 @@ public PooledObject makeObject() throws Exception {
*/
@Override
public void passivateObject(final PooledObject p)
- throws Exception {
+ throws E {
// The default implementation is a no-op.
}
diff --git a/src/main/java/org/apache/commons/pool2/KeyedObjectPool.java b/src/main/java/org/apache/commons/pool2/KeyedObjectPool.java
index 7b0960c0b..88a4fbc91 100644
--- a/src/main/java/org/apache/commons/pool2/KeyedObjectPool.java
+++ b/src/main/java/org/apache/commons/pool2/KeyedObjectPool.java
@@ -61,6 +61,7 @@
*
* @param The type of keys maintained by this pool.
* @param Type of element pooled in this pool.
+ * @param Type of exception thrown by this pool.
*
* @see KeyedPooledObjectFactory
* @see ObjectPool
@@ -68,7 +69,7 @@
*
* @since 2.0
*/
-public interface KeyedObjectPool extends Closeable {
+public interface KeyedObjectPool extends Closeable {
/**
* Creates an object using the {@link KeyedPooledObjectFactory factory} or
@@ -78,15 +79,14 @@ public interface KeyedObjectPool extends Closeable {
*
* @param key the key a new instance should be added to
*
- * @throws Exception
+ * @throws E
* when {@link KeyedPooledObjectFactory#makeObject} fails.
* @throws IllegalStateException
* after {@link #close} has been called on this pool.
* @throws UnsupportedOperationException
* when this pool cannot add new idle objects.
*/
- void addObject(K key) throws Exception, IllegalStateException,
- UnsupportedOperationException;
+ void addObject(K key) throws E, IllegalStateException, UnsupportedOperationException;
/**
* Calls {@link KeyedObjectPool#addObject(Object)} with each
@@ -98,14 +98,14 @@ void addObject(K key) throws Exception, IllegalStateException,
* {@link Collection} of keys to add objects for.
* @param count
* the number of idle objects to add for each {@code key}.
- * @throws Exception
+ * @throws E
* when {@link KeyedObjectPool#addObject(Object)} fails.
* @throws IllegalArgumentException
* when {@code keyedPool}, {@code keys}, or any value
* in {@code keys} is {@code null}.
* @see #addObjects(Object, int)
*/
- default void addObjects(final Collection keys, final int count) throws Exception, IllegalArgumentException {
+ default void addObjects(final Collection keys, final int count) throws E, IllegalArgumentException {
if (keys == null) {
throw new IllegalArgumentException(PoolUtils.MSG_NULL_KEYS);
}
@@ -122,13 +122,13 @@ default void addObjects(final Collection keys, final int count) throws Except
* the key to add objects for.
* @param count
* the number of idle objects to add for {@code key}.
- * @throws Exception
+ * @throws E
* when {@link KeyedObjectPool#addObject(Object)} fails.
* @throws IllegalArgumentException
* when {@code key} is {@code null}.
* @since 2.8.0
*/
- default void addObjects(final K key, final int count) throws Exception, IllegalArgumentException {
+ default void addObjects(final K key, final int count) throws E, IllegalArgumentException {
if (key == null) {
throw new IllegalArgumentException(PoolUtils.MSG_NULL_KEY);
}
@@ -166,14 +166,14 @@ default void addObjects(final K key, final int count) throws Exception, IllegalA
*
* @throws IllegalStateException
* after {@link #close close} has been called on this pool
- * @throws Exception
+ * @throws E
* when {@link KeyedPooledObjectFactory#makeObject
* makeObject} throws an exception
* @throws NoSuchElementException
* when the pool is exhausted and cannot or will not return
* another instance
*/
- V borrowObject(K key) throws Exception, NoSuchElementException, IllegalStateException;
+ V borrowObject(K key) throws E, NoSuchElementException, IllegalStateException;
/**
* Clears the pool, removing all pooled instances (optional operation).
@@ -181,9 +181,9 @@ default void addObjects(final K key, final int count) throws Exception, IllegalA
* @throws UnsupportedOperationException when this implementation doesn't
* support the operation
*
- * @throws Exception if the pool cannot be cleared
+ * @throws E if the pool cannot be cleared
*/
- void clear() throws Exception, UnsupportedOperationException;
+ void clear() throws E, UnsupportedOperationException;
/**
* Clears the specified pool, removing all pooled instances corresponding to
@@ -194,9 +194,9 @@ default void addObjects(final K key, final int count) throws Exception, IllegalA
* @throws UnsupportedOperationException when this implementation doesn't
* support the operation
*
- * @throws Exception if the key cannot be cleared
+ * @throws E if the key cannot be cleared
*/
- void clear(K key) throws Exception, UnsupportedOperationException;
+ void clear(K key) throws E, UnsupportedOperationException;
/**
* Closes this pool, and free any resources associated with it.
@@ -277,9 +277,9 @@ default List getKeys() {
* @param key the key used to obtain the object
* @param obj a {@link #borrowObject borrowed} instance to be returned.
*
- * @throws Exception if the instance cannot be invalidated
+ * @throws E if the instance cannot be invalidated
*/
- void invalidateObject(K key, V obj) throws Exception;
+ void invalidateObject(K key, V obj) throws E;
/**
* Invalidates an object from the pool, using the provided
@@ -300,10 +300,10 @@ default List getKeys() {
* @param obj a {@link #borrowObject borrowed} instance to be returned.
* @param destroyMode destroy activation context provided to the factory
*
- * @throws Exception if the instance cannot be invalidated
+ * @throws E if the instance cannot be invalidated
* @since 2.9.0
*/
- default void invalidateObject(final K key, final V obj, final DestroyMode destroyMode) throws Exception {
+ default void invalidateObject(final K key, final V obj, final DestroyMode destroyMode) throws E {
invalidateObject(key, obj);
}
@@ -324,7 +324,7 @@ default void invalidateObject(final K key, final V obj, final DestroyMode destro
* to return an object that was never borrowed from the pool
* will trigger this exception.
*
- * @throws Exception if an instance cannot be returned to the pool
+ * @throws E if an instance cannot be returned to the pool
*/
- void returnObject(K key, V obj) throws Exception;
+ void returnObject(K key, V obj) throws E;
}
diff --git a/src/main/java/org/apache/commons/pool2/KeyedPooledObjectFactory.java b/src/main/java/org/apache/commons/pool2/KeyedPooledObjectFactory.java
index a7f75a304..0a61497e5 100644
--- a/src/main/java/org/apache/commons/pool2/KeyedPooledObjectFactory.java
+++ b/src/main/java/org/apache/commons/pool2/KeyedPooledObjectFactory.java
@@ -71,10 +71,11 @@
*
* @param The type of keys managed by this factory.
* @param Type of element managed by this factory.
+ * @param Type of exception thrown by this factory.
*
* @since 2.0
*/
-public interface KeyedPooledObjectFactory {
+public interface KeyedPooledObjectFactory {
/**
* Reinitializes an instance to be returned by the pool.
@@ -82,12 +83,12 @@ public interface KeyedPooledObjectFactory {
* @param key the key used when selecting the object
* @param p a {@code PooledObject} wrapping the instance to be activated
*
- * @throws Exception if there is a problem activating {@code obj},
+ * @throws E if there is a problem activating {@code obj},
* this exception may be swallowed by the pool.
*
* @see #destroyObject
*/
- void activateObject(K key, PooledObject p) throws Exception;
+ void activateObject(K key, PooledObject p) throws E;
/**
* Destroys an instance no longer needed by the pool.
@@ -104,13 +105,13 @@ public interface KeyedPooledObjectFactory {
* @param key the key used when selecting the instance
* @param p a {@code PooledObject} wrapping the instance to be destroyed
*
- * @throws Exception should be avoided as it may be swallowed by
+ * @throws E should be avoided as it may be swallowed by
* the pool implementation.
*
* @see #validateObject
* @see KeyedObjectPool#invalidateObject
*/
- void destroyObject(K key, PooledObject p) throws Exception;
+ void destroyObject(K key, PooledObject p) throws E;
/**
* Destroys an instance no longer needed by the pool, using the provided {@link DestroyMode}.
@@ -119,7 +120,7 @@ public interface KeyedPooledObjectFactory {
* @param p a {@code PooledObject} wrapping the instance to be destroyed
* @param destroyMode DestroyMode providing context to the factory
*
- * @throws Exception should be avoided as it may be swallowed by
+ * @throws E should be avoided as it may be swallowed by
* the pool implementation.
*
* @see #validateObject
@@ -128,7 +129,7 @@ public interface KeyedPooledObjectFactory {
* @see DestroyMode
* @since 2.9.0
*/
- default void destroyObject(final K key, final PooledObject p, final DestroyMode destroyMode) throws Exception {
+ default void destroyObject(final K key, final PooledObject p, final DestroyMode destroyMode) throws E {
destroyObject(key, p);
}
@@ -141,10 +142,10 @@ default void destroyObject(final K key, final PooledObject p, final DestroyMo
* @return a {@code PooledObject} wrapping an instance that can
* be served by the pool.
*
- * @throws Exception if there is a problem creating a new instance,
+ * @throws E if there is a problem creating a new instance,
* this will be propagated to the code requesting an object.
*/
- PooledObject makeObject(K key) throws Exception;
+ PooledObject makeObject(K key) throws E;
/**
* Uninitializes an instance to be returned to the idle object pool.
@@ -152,12 +153,12 @@ default void destroyObject(final K key, final PooledObject p, final DestroyMo
* @param key the key used when selecting the object
* @param p a {@code PooledObject} wrapping the instance to be passivated
*
- * @throws Exception if there is a problem passivating {@code obj},
+ * @throws E if there is a problem passivating {@code obj},
* this exception may be swallowed by the pool.
*
* @see #destroyObject
*/
- void passivateObject(K key, PooledObject p) throws Exception;
+ void passivateObject(K key, PooledObject p) throws E;
/**
* Ensures that the instance is safe to be returned by the pool.
diff --git a/src/main/java/org/apache/commons/pool2/ObjectPool.java b/src/main/java/org/apache/commons/pool2/ObjectPool.java
index 8aa2d58aa..04f8e11d4 100644
--- a/src/main/java/org/apache/commons/pool2/ObjectPool.java
+++ b/src/main/java/org/apache/commons/pool2/ObjectPool.java
@@ -50,6 +50,7 @@
*
*
* @param Type of element pooled in this pool.
+ * @param Type of exception thrown by this pool.
*
* @see PooledObjectFactory
* @see KeyedObjectPool
@@ -57,7 +58,7 @@
*
* @since 2.0
*/
-public interface ObjectPool extends Closeable {
+public interface ObjectPool extends Closeable {
/**
* Creates an object using the {@link PooledObjectFactory factory} or other
@@ -65,15 +66,14 @@ public interface ObjectPool extends Closeable {
* the idle object pool. {@code addObject} is useful for "pre-loading"
* a pool with idle objects. (Optional operation).
*
- * @throws Exception
+ * @throws E
* when {@link PooledObjectFactory#makeObject} fails.
* @throws IllegalStateException
* after {@link #close} has been called on this pool.
* @throws UnsupportedOperationException
* when this pool cannot add new idle objects.
*/
- void addObject() throws Exception, IllegalStateException,
- UnsupportedOperationException;
+ void addObject() throws E, IllegalStateException, UnsupportedOperationException;
/**
* Calls {@link ObjectPool#addObject()} {@code count}
@@ -81,11 +81,10 @@ void addObject() throws Exception, IllegalStateException,
*
* @param count
* the number of idle objects to add.
- * @throws Exception
- * when {@link ObjectPool#addObject()} fails.
+ * @throws E See {@link ObjectPool#addObject()}.
* @since 2.8.0
*/
- default void addObjects(final int count) throws Exception {
+ default void addObjects(final int count) throws E {
for (int i = 0; i < count; i++) {
addObject();
}
@@ -115,15 +114,14 @@ default void addObjects(final int count) throws Exception {
*
* @throws IllegalStateException
* after {@link #close close} has been called on this pool.
- * @throws Exception
+ * @throws E
* when {@link PooledObjectFactory#makeObject} throws an
* exception.
* @throws NoSuchElementException
* when the pool is exhausted and cannot or will not return
* another instance.
*/
- T borrowObject() throws Exception, NoSuchElementException,
- IllegalStateException;
+ T borrowObject() throws E, NoSuchElementException, IllegalStateException;
/**
* Clears any objects sitting idle in the pool, releasing any associated
@@ -133,9 +131,9 @@ T borrowObject() throws Exception, NoSuchElementException,
* @throws UnsupportedOperationException
* if this implementation does not support the operation
*
- * @throws Exception if the pool cannot be cleared
+ * @throws E if the pool cannot be cleared
*/
- void clear() throws Exception, UnsupportedOperationException;
+ void clear() throws E, UnsupportedOperationException;
/**
* Closes this pool, and free any resources associated with it.
@@ -180,9 +178,9 @@ T borrowObject() throws Exception, NoSuchElementException,
*
* @param obj a {@link #borrowObject borrowed} instance to be disposed.
*
- * @throws Exception if the instance cannot be invalidated
+ * @throws E if the instance cannot be invalidated
*/
- void invalidateObject(T obj) throws Exception;
+ void invalidateObject(T obj) throws E;
/**
* Invalidates an object from the pool, using the provided
@@ -199,11 +197,10 @@ T borrowObject() throws Exception, NoSuchElementException,
*
* @param obj a {@link #borrowObject borrowed} instance to be disposed.
* @param destroyMode destroy activation context provided to the factory
- *
- * @throws Exception if the instance cannot be invalidated
+ * @throws E if the instance cannot be invalidated
* @since 2.9.0
*/
- default void invalidateObject(final T obj, final DestroyMode destroyMode) throws Exception {
+ default void invalidateObject(final T obj, final DestroyMode destroyMode) throws E {
invalidateObject(obj);
}
@@ -221,8 +218,8 @@ default void invalidateObject(final T obj, final DestroyMode destroyMode) throws
* to return an object that was never borrowed from the pool
* will trigger this exception.
*
- * @throws Exception if an instance cannot be returned to the pool
+ * @throws E if an instance cannot be returned to the pool
*/
- void returnObject(T obj) throws Exception;
+ void returnObject(T obj) throws E;
}
diff --git a/src/main/java/org/apache/commons/pool2/PoolUtils.java b/src/main/java/org/apache/commons/pool2/PoolUtils.java
index 023b040c7..7d64d9ae4 100644
--- a/src/main/java/org/apache/commons/pool2/PoolUtils.java
+++ b/src/main/java/org/apache/commons/pool2/PoolUtils.java
@@ -110,12 +110,12 @@ public void update(final long nowMillis, final int numIdle) {
*
* @param object pool key type
* @param object pool value type
+ * @param exception thrown by this pool
*/
- private static class ErodingKeyedObjectPool implements
- KeyedObjectPool {
+ private static class ErodingKeyedObjectPool implements KeyedObjectPool {
/** Underlying pool */
- private final KeyedObjectPool keyedPool;
+ private final KeyedObjectPool keyedPool;
/** Erosion factor */
private final ErodingFactor erodingFactor;
@@ -131,7 +131,7 @@ private static class ErodingKeyedObjectPool implements
* events
* @see #erodingFactor
*/
- protected ErodingKeyedObjectPool(final KeyedObjectPool keyedPool,
+ protected ErodingKeyedObjectPool(final KeyedObjectPool keyedPool,
final ErodingFactor erodingFactor) {
if (keyedPool == null) {
throw new IllegalArgumentException(
@@ -152,7 +152,7 @@ protected ErodingKeyedObjectPool(final KeyedObjectPool keyedPool,
* events
* @see #erodingFactor
*/
- public ErodingKeyedObjectPool(final KeyedObjectPool keyedPool,
+ public ErodingKeyedObjectPool(final KeyedObjectPool keyedPool,
final float factor) {
this(keyedPool, new ErodingFactor(factor));
}
@@ -161,8 +161,7 @@ public ErodingKeyedObjectPool(final KeyedObjectPool keyedPool,
* {@inheritDoc}
*/
@Override
- public void addObject(final K key) throws Exception,
- IllegalStateException, UnsupportedOperationException {
+ public void addObject(final K key) throws E, IllegalStateException, UnsupportedOperationException {
keyedPool.addObject(key);
}
@@ -170,8 +169,7 @@ public void addObject(final K key) throws Exception,
* {@inheritDoc}
*/
@Override
- public V borrowObject(final K key) throws Exception,
- NoSuchElementException, IllegalStateException {
+ public V borrowObject(final K key) throws E, NoSuchElementException, IllegalStateException {
return keyedPool.borrowObject(key);
}
@@ -179,7 +177,7 @@ public V borrowObject(final K key) throws Exception,
* {@inheritDoc}
*/
@Override
- public void clear() throws Exception, UnsupportedOperationException {
+ public void clear() throws E, UnsupportedOperationException {
keyedPool.clear();
}
@@ -187,8 +185,7 @@ public void clear() throws Exception, UnsupportedOperationException {
* {@inheritDoc}
*/
@Override
- public void clear(final K key) throws Exception,
- UnsupportedOperationException {
+ public void clear(final K key) throws E, UnsupportedOperationException {
keyedPool.clear(key);
}
@@ -220,7 +217,7 @@ protected ErodingFactor getErodingFactor(final K key) {
*
* @return the keyed pool that this ErodingKeyedObjectPool wraps
*/
- protected KeyedObjectPool getKeyedPool() {
+ protected KeyedObjectPool getKeyedPool() {
return keyedPool;
}
@@ -290,7 +287,7 @@ public void invalidateObject(final K key, final V obj) {
* @see #erodingFactor
*/
@Override
- public void returnObject(final K key, final V obj) throws Exception {
+ public void returnObject(final K key, final V obj) throws E {
boolean discard = false;
final long nowMillis = System.currentTimeMillis();
final ErodingFactor factor = getErodingFactor(key);
@@ -324,17 +321,19 @@ public String toString() {
erodingFactor + ", keyedPool=" + keyedPool + '}';
}
}
+
/**
* Decorates an object pool, adding "eroding" behavior. Based on the
* configured {@link #factor erosion factor}, objects returning to the pool
* may be invalidated instead of being added to idle capacity.
*
* @param type of objects in the pool
+ * @param type of exceptions from the pool
*/
- private static class ErodingObjectPool implements ObjectPool {
+ private static class ErodingObjectPool implements ObjectPool {
/** Underlying object pool */
- private final ObjectPool pool;
+ private final ObjectPool pool;
/** Erosion factor */
private final ErodingFactor factor;
@@ -350,7 +349,7 @@ private static class ErodingObjectPool implements ObjectPool {
* events
* @see #factor
*/
- public ErodingObjectPool(final ObjectPool pool, final float factor) {
+ public ErodingObjectPool(final ObjectPool pool, final float factor) {
this.pool = pool;
this.factor = new ErodingFactor(factor);
}
@@ -359,8 +358,7 @@ public ErodingObjectPool(final ObjectPool pool, final float factor) {
* {@inheritDoc}
*/
@Override
- public void addObject() throws Exception, IllegalStateException,
- UnsupportedOperationException {
+ public void addObject() throws E, IllegalStateException, UnsupportedOperationException{
pool.addObject();
}
@@ -368,8 +366,7 @@ public void addObject() throws Exception, IllegalStateException,
* {@inheritDoc}
*/
@Override
- public T borrowObject() throws Exception, NoSuchElementException,
- IllegalStateException {
+ public T borrowObject() throws E, NoSuchElementException, IllegalStateException {
return pool.borrowObject();
}
@@ -377,7 +374,7 @@ public T borrowObject() throws Exception, NoSuchElementException,
* {@inheritDoc}
*/
@Override
- public void clear() throws Exception, UnsupportedOperationException {
+ public void clear() throws E, UnsupportedOperationException {
pool.clear();
}
@@ -474,9 +471,9 @@ public String toString() {
*
* @param object pool key type
* @param object pool value type
+ * @param exception thrown by this pool
*/
- private static final class ErodingPerKeyKeyedObjectPool extends
- ErodingKeyedObjectPool {
+ private static final class ErodingPerKeyKeyedObjectPool extends ErodingKeyedObjectPool {
/** Erosion factor - same for all pools */
private final float factor;
@@ -493,8 +490,7 @@ private static final class ErodingPerKeyKeyedObjectPool extends
* @param factor
* erosion factor
*/
- public ErodingPerKeyKeyedObjectPool(
- final KeyedObjectPool keyedPool, final float factor) {
+ public ErodingPerKeyKeyedObjectPool(final KeyedObjectPool keyedPool, final float factor) {
super(keyedPool, null);
this.factor = factor;
}
@@ -531,9 +527,9 @@ public String toString() {
*
* @param object pool key type
* @param object pool value type
+ * @param exception thrown by this pool
*/
- private static final class KeyedObjectPoolMinIdleTimerTask extends
- TimerTask {
+ private static final class KeyedObjectPoolMinIdleTimerTask extends TimerTask {
/** Minimum number of idle instances. Not the same as pool.getMinIdle(). */
private final int minIdle;
@@ -542,7 +538,7 @@ private static final class KeyedObjectPoolMinIdleTimerTask extends
private final K key;
/** Keyed object pool */
- private final KeyedObjectPool keyedPool;
+ private final KeyedObjectPool keyedPool;
/**
* Creates a new KeyedObjecPoolMinIdleTimerTask.
@@ -556,7 +552,7 @@ private static final class KeyedObjectPoolMinIdleTimerTask extends
* @throws IllegalArgumentException
* if the key is null
*/
- KeyedObjectPoolMinIdleTimerTask(final KeyedObjectPool keyedPool,
+ KeyedObjectPoolMinIdleTimerTask(final KeyedObjectPool keyedPool,
final K key, final int minIdle) throws IllegalArgumentException {
if (keyedPool == null) {
throw new IllegalArgumentException(
@@ -610,14 +606,15 @@ public String toString() {
* as the pool's minIdle setting.
*
* @param type of objects in the pool
+ * @param type of exceptions from the pool
*/
- private static final class ObjectPoolMinIdleTimerTask extends TimerTask {
+ private static final class ObjectPoolMinIdleTimerTask extends TimerTask {
/** Minimum number of idle instances. Not the same as pool.getMinIdle(). */
private final int minIdle;
/** Object pool */
- private final ObjectPool pool;
+ private final ObjectPool pool;
/**
* Constructs a new ObjectPoolMinIdleTimerTask for the given pool with the
@@ -630,7 +627,7 @@ private static final class ObjectPoolMinIdleTimerTask extends TimerTask {
* @throws IllegalArgumentException
* if the pool is null
*/
- ObjectPoolMinIdleTimerTask(final ObjectPool pool, final int minIdle)
+ ObjectPoolMinIdleTimerTask(final ObjectPool pool, final int minIdle)
throws IllegalArgumentException {
if (pool == null) {
throw new IllegalArgumentException(MSG_NULL_POOL);
@@ -689,9 +686,9 @@ public String toString() {
*
* @param object pool key type
* @param object pool value type
+ * @param exception thrown by this pool
*/
- static final class SynchronizedKeyedObjectPool implements
- KeyedObjectPool {
+ static final class SynchronizedKeyedObjectPool implements KeyedObjectPool {
/**
* Object whose monitor is used to synchronize methods on the wrapped
@@ -700,7 +697,7 @@ static final class SynchronizedKeyedObjectPool implements
private final ReentrantReadWriteLock readWriteLock = new ReentrantReadWriteLock();
/** Underlying object pool */
- private final KeyedObjectPool keyedPool;
+ private final KeyedObjectPool keyedPool;
/**
* Creates a new SynchronizedKeyedObjectPool wrapping the given pool
@@ -710,7 +707,7 @@ static final class SynchronizedKeyedObjectPool implements
* @throws IllegalArgumentException
* if keyedPool is null
*/
- SynchronizedKeyedObjectPool(final KeyedObjectPool keyedPool)
+ SynchronizedKeyedObjectPool(final KeyedObjectPool keyedPool)
throws IllegalArgumentException {
if (keyedPool == null) {
throw new IllegalArgumentException(
@@ -723,8 +720,7 @@ static final class SynchronizedKeyedObjectPool implements
* {@inheritDoc}
*/
@Override
- public void addObject(final K key) throws Exception,
- IllegalStateException, UnsupportedOperationException {
+ public void addObject(final K key) throws E, IllegalStateException, UnsupportedOperationException {
final WriteLock writeLock = readWriteLock.writeLock();
writeLock.lock();
try {
@@ -738,8 +734,7 @@ public void addObject(final K key) throws Exception,
* {@inheritDoc}
*/
@Override
- public V borrowObject(final K key) throws Exception,
- NoSuchElementException, IllegalStateException {
+ public V borrowObject(final K key) throws E, NoSuchElementException, IllegalStateException {
final WriteLock writeLock = readWriteLock.writeLock();
writeLock.lock();
try {
@@ -753,7 +748,7 @@ public V borrowObject(final K key) throws Exception,
* {@inheritDoc}
*/
@Override
- public void clear() throws Exception, UnsupportedOperationException {
+ public void clear() throws E, UnsupportedOperationException {
final WriteLock writeLock = readWriteLock.writeLock();
writeLock.lock();
try {
@@ -767,8 +762,7 @@ public void clear() throws Exception, UnsupportedOperationException {
* {@inheritDoc}
*/
@Override
- public void clear(final K key) throws Exception,
- UnsupportedOperationException {
+ public void clear(final K key) throws E, UnsupportedOperationException {
final WriteLock writeLock = readWriteLock.writeLock();
writeLock.lock();
try {
@@ -920,16 +914,16 @@ public String toString() {
*
*
* @param pooled object factory key type
- * @param pooled object factory key value
+ * @param pooled object factory value type
+ * @param pooled object factory exception type
*/
- private static final class SynchronizedKeyedPooledObjectFactory
- implements KeyedPooledObjectFactory {
+ private static final class SynchronizedKeyedPooledObjectFactory implements KeyedPooledObjectFactory {
/** Synchronization lock */
private final WriteLock writeLock = new ReentrantReadWriteLock().writeLock();
/** Wrapped factory */
- private final KeyedPooledObjectFactory keyedFactory;
+ private final KeyedPooledObjectFactory keyedFactory;
/**
* Creates a SynchronizedKeyedPoolableObjectFactory wrapping the given
@@ -940,9 +934,7 @@ private static final class SynchronizedKeyedPooledObjectFactory
* @throws IllegalArgumentException
* if the factory is null
*/
- SynchronizedKeyedPooledObjectFactory(
- final KeyedPooledObjectFactory keyedFactory)
- throws IllegalArgumentException {
+ SynchronizedKeyedPooledObjectFactory(final KeyedPooledObjectFactory keyedFactory) throws IllegalArgumentException {
if (keyedFactory == null) {
throw new IllegalArgumentException(
"keyedFactory must not be null.");
@@ -954,7 +946,7 @@ private static final class SynchronizedKeyedPooledObjectFactory
* {@inheritDoc}
*/
@Override
- public void activateObject(final K key, final PooledObject p) throws Exception {
+ public void activateObject(final K key, final PooledObject p) throws E {
writeLock.lock();
try {
keyedFactory.activateObject(key, p);
@@ -967,7 +959,7 @@ public void activateObject(final K key, final PooledObject p) throws Exceptio
* {@inheritDoc}
*/
@Override
- public void destroyObject(final K key, final PooledObject p) throws Exception {
+ public void destroyObject(final K key, final PooledObject p) throws E {
writeLock.lock();
try {
keyedFactory.destroyObject(key, p);
@@ -980,7 +972,7 @@ public void destroyObject(final K key, final PooledObject p) throws Exception
* {@inheritDoc}
*/
@Override
- public PooledObject makeObject(final K key) throws Exception {
+ public PooledObject makeObject(final K key) throws E {
writeLock.lock();
try {
return keyedFactory.makeObject(key);
@@ -993,7 +985,7 @@ public PooledObject makeObject(final K key) throws Exception {
* {@inheritDoc}
*/
@Override
- public void passivateObject(final K key, final PooledObject p) throws Exception {
+ public void passivateObject(final K key, final PooledObject p) throws E {
writeLock.lock();
try {
keyedFactory.passivateObject(key, p);
@@ -1041,8 +1033,9 @@ public boolean validateObject(final K key, final PooledObject p) {
*
*
* @param type of objects in the pool
+ * @param type of exceptions from the pool
*/
- private static final class SynchronizedObjectPool implements ObjectPool {
+ private static final class SynchronizedObjectPool implements ObjectPool {
/**
* Object whose monitor is used to synchronize methods on the wrapped
@@ -1051,7 +1044,7 @@ private static final class SynchronizedObjectPool implements ObjectPool {
private final ReentrantReadWriteLock readWriteLock = new ReentrantReadWriteLock();
/** the underlying object pool */
- private final ObjectPool pool;
+ private final ObjectPool pool;
/**
* Creates a new SynchronizedObjectPool wrapping the given pool.
@@ -1062,7 +1055,7 @@ private static final class SynchronizedObjectPool implements ObjectPool {
* @throws IllegalArgumentException
* if the pool is null
*/
- SynchronizedObjectPool(final ObjectPool pool)
+ SynchronizedObjectPool(final ObjectPool pool)
throws IllegalArgumentException {
if (pool == null) {
throw new IllegalArgumentException(MSG_NULL_POOL);
@@ -1074,8 +1067,7 @@ private static final class SynchronizedObjectPool implements ObjectPool {
* {@inheritDoc}
*/
@Override
- public void addObject() throws Exception, IllegalStateException,
- UnsupportedOperationException {
+ public void addObject() throws E, IllegalStateException, UnsupportedOperationException {
final WriteLock writeLock = readWriteLock.writeLock();
writeLock.lock();
try {
@@ -1089,8 +1081,7 @@ public void addObject() throws Exception, IllegalStateException,
* {@inheritDoc}
*/
@Override
- public T borrowObject() throws Exception, NoSuchElementException,
- IllegalStateException {
+ public T borrowObject() throws E, NoSuchElementException, IllegalStateException {
final WriteLock writeLock = readWriteLock.writeLock();
writeLock.lock();
try {
@@ -1104,7 +1095,7 @@ public T borrowObject() throws Exception, NoSuchElementException,
* {@inheritDoc}
*/
@Override
- public void clear() throws Exception, UnsupportedOperationException {
+ public void clear() throws E, UnsupportedOperationException {
final WriteLock writeLock = readWriteLock.writeLock();
writeLock.lock();
try {
@@ -1214,15 +1205,16 @@ public String toString() {
*
*
* @param pooled object factory type
+ * @param exception type
*/
- private static final class SynchronizedPooledObjectFactory implements
- PooledObjectFactory {
+ private static final class SynchronizedPooledObjectFactory implements
+ PooledObjectFactory {
/** Synchronization lock */
private final WriteLock writeLock = new ReentrantReadWriteLock().writeLock();
/** Wrapped factory */
- private final PooledObjectFactory factory;
+ private final PooledObjectFactory factory;
/**
* Creates a SynchronizedPoolableObjectFactory wrapping the given
@@ -1233,7 +1225,7 @@ private static final class SynchronizedPooledObjectFactory implements
* @throws IllegalArgumentException
* if the factory is null
*/
- SynchronizedPooledObjectFactory(final PooledObjectFactory factory)
+ SynchronizedPooledObjectFactory(final PooledObjectFactory factory)
throws IllegalArgumentException {
if (factory == null) {
throw new IllegalArgumentException("factory must not be null.");
@@ -1245,7 +1237,7 @@ private static final class SynchronizedPooledObjectFactory implements
* {@inheritDoc}
*/
@Override
- public void activateObject(final PooledObject p) throws Exception {
+ public void activateObject(final PooledObject p) throws E {
writeLock.lock();
try {
factory.activateObject(p);
@@ -1258,7 +1250,7 @@ public void activateObject(final PooledObject p) throws Exception {
* {@inheritDoc}
*/
@Override
- public void destroyObject(final PooledObject p) throws Exception {
+ public void destroyObject(final PooledObject p) throws E {
writeLock.lock();
try {
factory.destroyObject(p);
@@ -1271,7 +1263,7 @@ public void destroyObject(final PooledObject p) throws Exception {
* {@inheritDoc}
*/
@Override
- public PooledObject makeObject() throws Exception {
+ public PooledObject makeObject() throws E {
writeLock.lock();
try {
return factory.makeObject();
@@ -1284,7 +1276,7 @@ public PooledObject makeObject() throws Exception {
* {@inheritDoc}
*/
@Override
- public void passivateObject(final PooledObject p) throws Exception {
+ public void passivateObject(final PooledObject p) throws E {
writeLock.lock();
try {
factory.passivateObject(p);
@@ -1356,6 +1348,7 @@ static class TimerHolder {
* keyedPool, see {@link Timer#schedule(TimerTask, long, long)}.
* @param the type of the pool key
* @param the type of pool entries
+ * @param the type of exception thrown by a pool
* @return a {@link Map} of key and {@link TimerTask} pairs that will
* periodically check the pools idle object count.
* @throws IllegalArgumentException
@@ -1365,8 +1358,8 @@ static class TimerHolder {
* {@link Timer#schedule(TimerTask, long, long)}.
* @see #checkMinIdle(KeyedObjectPool, Object, int, long)
*/
- public static Map checkMinIdle(
- final KeyedObjectPool keyedPool, final Collection keys,
+ public static Map checkMinIdle(
+ final KeyedObjectPool keyedPool, final Collection keys,
final int minIdle, final long periodMillis)
throws IllegalArgumentException {
if (keys == null) {
@@ -1398,6 +1391,7 @@ public static Map checkMinIdle(
* keyedPool, see {@link Timer#schedule(TimerTask, long, long)}.
* @param the type of the pool key
* @param the type of pool entries
+ * @param the type of exception thrown by a pool
* @return the {@link TimerTask} that will periodically check the pools idle
* object count.
* @throws IllegalArgumentException
@@ -1405,8 +1399,8 @@ public static Map checkMinIdle(
* when {@code minIdle} is negative or when {@code period} isn't
* valid for {@link Timer#schedule(TimerTask, long, long)}.
*/
- public static TimerTask checkMinIdle(
- final KeyedObjectPool keyedPool, final K key,
+ public static TimerTask checkMinIdle(
+ final KeyedObjectPool keyedPool, final K key,
final int minIdle, final long periodMillis)
throws IllegalArgumentException {
if (keyedPool == null) {
@@ -1438,6 +1432,7 @@ public static TimerTask checkMinIdle(
* the frequency in milliseconds to check the number of idle objects in a pool,
* see {@link Timer#schedule(TimerTask, long, long)}.
* @param the type of objects in the pool
+ * @param type of exceptions from the pool
* @return the {@link TimerTask} that will periodically check the pools idle
* object count.
* @throws IllegalArgumentException
@@ -1445,7 +1440,7 @@ public static TimerTask checkMinIdle(
* negative or when {@code period} isn't valid for
* {@link Timer#schedule(TimerTask, long, long)}
*/
- public static TimerTask checkMinIdle(final ObjectPool pool,
+ public static TimerTask checkMinIdle(final ObjectPool pool,
final int minIdle, final long periodMillis)
throws IllegalArgumentException {
if (pool == null) {
@@ -1494,6 +1489,7 @@ public static void checkRethrow(final Throwable t) {
* count when possible.
* @param the type of the pool key
* @param the type of pool entries
+ * @param the type of exception thrown by a pool
* @throws IllegalArgumentException
* when {@code keyedPool} is {@code null}.
* @return a pool that adaptively decreases its size when idle objects are
@@ -1501,8 +1497,7 @@ public static void checkRethrow(final Throwable t) {
* @see #erodingPool(KeyedObjectPool, float)
* @see #erodingPool(KeyedObjectPool, float, boolean)
*/
- public static KeyedObjectPool erodingPool(
- final KeyedObjectPool keyedPool) {
+ public static KeyedObjectPool erodingPool(final KeyedObjectPool keyedPool) {
return erodingPool(keyedPool, 1f);
}
@@ -1529,6 +1524,7 @@ public static KeyedObjectPool erodingPool(
* shrinks less aggressively.
* @param the type of the pool key
* @param the type of pool entries
+ * @param the type of exception thrown by a pool
* @throws IllegalArgumentException
* when {@code keyedPool} is {@code null} or when {@code factor}
* is not positive.
@@ -1536,8 +1532,7 @@ public static KeyedObjectPool erodingPool(
* no longer needed.
* @see #erodingPool(KeyedObjectPool, float, boolean)
*/
- public static KeyedObjectPool erodingPool(
- final KeyedObjectPool keyedPool, final float factor) {
+ public static KeyedObjectPool erodingPool(final KeyedObjectPool keyedPool, final float factor) {
return erodingPool(keyedPool, factor, false);
}
@@ -1572,6 +1567,7 @@ public static KeyedObjectPool