Author: markt
Date: Thu Aug 9 14:51:00 2018
New Revision: 1837737
URL: http://svn.apache.org/viewvc?rev=1837737&view=rev
Log:
Update the internal fork of Apache Commons Pool 2 to 3e02523 (2018-08-09) to
pick up some bug fixes and enhancements.
Modified:
tomcat/trunk/MERGE.txt
tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/BaseKeyedPooledObjectFactory.java
tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/BaseObjectPool.java
tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/KeyedObjectPool.java
tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/KeyedPooledObjectFactory.java
tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/ObjectPool.java
tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/PooledObject.java
tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/PooledObjectFactory.java
tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/impl/BaseGenericObjectPool.java
tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/impl/DefaultPooledObject.java
tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/impl/GenericKeyedObjectPool.java
tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/impl/GenericObjectPool.java
tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/impl/GenericObjectPoolMXBean.java
tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/impl/PoolImplUtils.java
tomcat/trunk/webapps/docs/changelog.xml
Modified: tomcat/trunk/MERGE.txt
URL:
http://svn.apache.org/viewvc/tomcat/trunk/MERGE.txt?rev=1837737&r1=1837736&r2=1837737&view=diff
==============================================================================
--- tomcat/trunk/MERGE.txt (original)
+++ tomcat/trunk/MERGE.txt Thu Aug 9 14:51:00 2018
@@ -75,4 +75,4 @@ Pool2
Sub-tree
src/main/java/org/apache/commons/pool2
The SHA1 ID for the most recent commit to be merged to Tomcat is:
-dfef97be70e8b1c3edb44b972fc7f700f3fe6255
+3e02523b6907fb22f3582544fe362c785821bcb8
Modified:
tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/BaseKeyedPooledObjectFactory.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/BaseKeyedPooledObjectFactory.java?rev=1837737&r1=1837736&r2=1837737&view=diff
==============================================================================
---
tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/BaseKeyedPooledObjectFactory.java
(original)
+++
tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/BaseKeyedPooledObjectFactory.java
Thu Aug 9 14:51:00 2018
@@ -30,8 +30,8 @@ package org.apache.tomcat.dbcp.pool2;
*
* @since 2.0
*/
-public abstract class BaseKeyedPooledObjectFactory<K,V> extends BaseObject
- implements KeyedPooledObjectFactory<K,V> {
+public abstract class BaseKeyedPooledObjectFactory<K, V> extends BaseObject
+ implements KeyedPooledObjectFactory<K, V> {
/**
* Create an instance that can be served by the pool.
@@ -64,6 +64,7 @@ public abstract class BaseKeyedPooledObj
* Destroy an instance no longer needed by the pool.
* <p>
* The default implementation is a no-op.
+ * </p>
*
* @param key the key used when selecting the instance
* @param p a {@code PooledObject} wrapping the instance to be destroyed
@@ -78,6 +79,7 @@ public abstract class BaseKeyedPooledObj
* Ensures that the instance is safe to be returned by the pool.
* <p>
* The default implementation always returns {@code true}.
+ * </p>
*
* @param key the key used when selecting the object
* @param p a {@code PooledObject} wrapping the instance to be validated
@@ -92,6 +94,7 @@ public abstract class BaseKeyedPooledObj
* Reinitialize an instance to be returned by the pool.
* <p>
* The default implementation is a no-op.
+ * </p>
*
* @param key the key used when selecting the object
* @param p a {@code PooledObject} wrapping the instance to be activated
@@ -106,6 +109,7 @@ public abstract class BaseKeyedPooledObj
* Uninitialize an instance to be returned to the idle object pool.
* <p>
* The default implementation is a no-op.
+ * </p>
*
* @param key the key used when selecting the object
* @param p a {@code PooledObject} wrapping the instance to be passivated
Modified: tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/BaseObjectPool.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/BaseObjectPool.java?rev=1837737&r1=1837736&r2=1837737&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/BaseObjectPool.java
(original)
+++ tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/BaseObjectPool.java Thu Aug
9 14:51:00 2018
@@ -86,6 +86,7 @@ public abstract class BaseObjectPool<T>
* <p>
* This affects the behavior of <code>isClosed</code> and
* <code>assertOpen</code>.
+ * </p>
*/
@Override
public void close() {
Modified: tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/KeyedObjectPool.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/KeyedObjectPool.java?rev=1837737&r1=1837736&r2=1837737&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/KeyedObjectPool.java
(original)
+++ tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/KeyedObjectPool.java Thu Aug
9 14:51:00 2018
@@ -23,8 +23,10 @@ import java.util.NoSuchElementException;
* A "keyed" pooling interface.
* <p>
* A keyed pool maintains a pool of instances for each key value.
+ * </p>
* <p>
* Example of use:
+ * </p>
* <pre style="border:solid thin; padding: 1ex;"
* > Object obj = <code style="color:#00C">null</code>;
* Object key = <code style="color:#C00">"Key"</code>;
@@ -48,9 +50,11 @@ import java.util.NoSuchElementException;
* one instance per key value, or may choose to maintain a pool of instances
* for each key (essentially creating a {@link java.util.Map Map} of
* {@link ObjectPool pools}).
+ * </p>
* <p>
* See {@link org.apache.tomcat.dbcp.pool2.impl.GenericKeyedObjectPool
* GenericKeyedObjectPool} for an implementation.
+ * </p>
*
* @param <K> The type of keys maintained by this pool.
* @param <V> Type of element pooled in this pool.
@@ -61,7 +65,7 @@ import java.util.NoSuchElementException;
*
* @since 2.0
*/
-public interface KeyedObjectPool<K,V> extends Closeable {
+public interface KeyedObjectPool<K, V> extends Closeable {
/**
* Obtains an instance from this pool for the specified <code>key</code>.
* <p>
@@ -71,6 +75,7 @@ public interface KeyedObjectPool<K,V> ex
* {@link KeyedPooledObjectFactory#activateObject activateObject} and then
* (optionally) validated with
* {@link KeyedPooledObjectFactory#validateObject validateObject}.
+ * </p>
* <p>
* By contract, clients <strong>must</strong> return the borrowed object
* using {@link #returnObject returnObject},
@@ -78,9 +83,11 @@ public interface KeyedObjectPool<K,V> ex
* defined in an implementation or sub-interface, using a <code>key</code>
* that is {@link Object#equals equivalent} to the one used to borrow the
* instance in the first place.
+ * </p>
* <p>
* The behaviour of this method when the pool has been exhausted is not
* strictly specified (although it may be specified by implementations).
+ * </p>
*
* @param key the key used to obtain the object
*
@@ -126,9 +133,11 @@ public interface KeyedObjectPool<K,V> ex
* 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>
* <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.
+ * </p>
*
* @param key the key used to obtain the object
* @param obj a {@link #borrowObject borrowed} instance to be returned.
@@ -222,8 +231,10 @@ public interface KeyedObjectPool<K,V> ex
* Calling {@link #addObject addObject} or
* {@link #borrowObject borrowObject} after invoking this method on a pool
* will cause them to throw an {@link IllegalStateException}.
+ * </p>
* <p>
* Implementations should silently fail if not all resources can be freed.
+ * </p>
*/
@Override
void close();
Modified:
tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/KeyedPooledObjectFactory.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/KeyedPooledObjectFactory.java?rev=1837737&r1=1837736&r2=1837737&view=diff
==============================================================================
---
tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/KeyedPooledObjectFactory.java
(original)
+++
tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/KeyedPooledObjectFactory.java
Thu Aug 9 14:51:00 2018
@@ -22,6 +22,7 @@ package org.apache.tomcat.dbcp.pool2;
* <p>
* By contract, when an {@link KeyedObjectPool}
* delegates to a {@link KeyedPooledObjectFactory},
+ * </p>
* <ol>
* <li>
* {@link #makeObject} is called whenever a new instance is needed.
@@ -63,6 +64,7 @@ package org.apache.tomcat.dbcp.pool2;
* {@link PooledObject PooledObject<V>}. These are the object wrappers
that
* pools use to track and maintain state informations about the objects that
* they manage.
+ * </p>
*
* @see KeyedObjectPool
* @see BaseKeyedPooledObjectFactory
@@ -72,7 +74,8 @@ package org.apache.tomcat.dbcp.pool2;
*
* @since 2.0
*/
-public interface KeyedPooledObjectFactory<K,V> {
+public interface KeyedPooledObjectFactory<K, V> {
+
/**
* Create an instance that can be served by the pool and
* wrap it in a {@link PooledObject} to be managed by the pool.
@@ -93,9 +96,11 @@ public interface KeyedPooledObjectFactor
* It is important for implementations of this method to be aware that
there
* is no guarantee about what state <code>obj</code> will be in and the
* implementation should be prepared to handle unexpected errors.
+ * </p>
* <p>
* Also, an implementation must take in to consideration that instances
lost
* to the garbage collector may never be destroyed.
+ * </p>
*
* @param key the key used when selecting the instance
* @param p a {@code PooledObject} wrapping the instance to be destroyed
Modified: tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/ObjectPool.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/ObjectPool.java?rev=1837737&r1=1837736&r2=1837737&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/ObjectPool.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/ObjectPool.java Thu Aug 9
14:51:00 2018
@@ -23,6 +23,7 @@ import java.util.NoSuchElementException;
* A pooling simple interface.
* <p>
* Example of use:
+ * </p>
* <pre style="border:solid thin; padding: 1ex;"
* > Object obj = <code style="color:#00C">null</code>;
*
@@ -46,6 +47,7 @@ import java.util.NoSuchElementException;
* }</pre>
* <p>
* See {@link BaseObjectPool} for a simple base implementation.
+ * </p>
*
* @param <T> Type of element pooled in this pool.
*
@@ -65,14 +67,17 @@ public interface ObjectPool<T> extends C
* idle object and have been activated with
* {@link PooledObjectFactory#activateObject} and then validated with
* {@link PooledObjectFactory#validateObject}.
+ * </p>
* <p>
* By contract, clients <strong>must</strong> return the borrowed instance
* using {@link #returnObject}, {@link #invalidateObject}, or a related
* method as defined in an implementation or sub-interface.
+ * </p>
* <p>
* The behaviour of this method when the pool has been exhausted
* is not strictly specified (although it may be specified by
* implementations).
+ * </p>
*
* @return an instance from this pool.
*
@@ -112,9 +117,11 @@ public interface ObjectPool<T> extends C
* By contract, <code>obj</code> <strong>must</strong> have been obtained
* using {@link #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.
+ * </p>
*
* @param obj a {@link #borrowObject borrowed} instance to be disposed.
*
@@ -171,8 +178,10 @@ public interface ObjectPool<T> extends C
* <p>
* Calling {@link #addObject} or {@link #borrowObject} after invoking this
* method on a pool will cause them to throw an {@link
IllegalStateException}.
+ * </p>
* <p>
* Implementations should silently fail if not all resources can be freed.
+ * </p>
*/
@Override
void close();
Modified: tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/PooledObject.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/PooledObject.java?rev=1837737&r1=1837736&r2=1837737&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/PooledObject.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/PooledObject.java Thu Aug 9
14:51:00 2018
@@ -96,8 +96,10 @@ public interface PooledObject<T> extends
*<p>
* Note: This class has a natural ordering that is inconsistent with
* equals if distinct objects have the same identity hash code.
+ * </p>
* <p>
* {@inheritDoc}
+ * </p>
*/
@Override
int compareTo(PooledObject<T> other);
Modified:
tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/PooledObjectFactory.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/PooledObjectFactory.java?rev=1837737&r1=1837736&r2=1837737&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/PooledObjectFactory.java
(original)
+++ tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/PooledObjectFactory.java Thu
Aug 9 14:51:00 2018
@@ -22,6 +22,7 @@ package org.apache.tomcat.dbcp.pool2;
* <p>
* By contract, when an {@link ObjectPool} delegates to a
* {@link PooledObjectFactory},
+ * </p>
* <ol>
* <li>
* {@link #makeObject} is called whenever a new instance is needed.
@@ -61,6 +62,7 @@ package org.apache.tomcat.dbcp.pool2;
* {@link PooledObject PooledObject<V>}. These are the object wrappers
that
* pools use to track and maintain state information about the objects that
* they manage.
+ * </p>
*
* @param <T> Type of element managed in this factory.
*
@@ -87,6 +89,7 @@ public interface PooledObjectFactory<T>
* It is important for implementations of this method to be aware that there
* is no guarantee about what state <code>obj</code> will be in and the
* implementation should be prepared to handle unexpected errors.
+ * </p>
* <p>
* Also, an implementation must take in to consideration that instances lost
* to the garbage collector may never be destroyed.
Modified:
tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/impl/BaseGenericObjectPool.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/impl/BaseGenericObjectPool.java?rev=1837737&r1=1837736&r2=1837737&view=diff
==============================================================================
---
tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/impl/BaseGenericObjectPool.java
(original)
+++
tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/impl/BaseGenericObjectPool.java
Thu Aug 9 14:51:00 2018
@@ -217,6 +217,29 @@ public abstract class BaseGenericObjectP
this.blockWhenExhausted = blockWhenExhausted;
}
+ protected void setConfig(BaseObjectPoolConfig<T> conf) {
+ setLifo(conf.getLifo());
+ setMaxWaitMillis(conf.getMaxWaitMillis());
+ setBlockWhenExhausted(conf.getBlockWhenExhausted());
+ setTestOnCreate(conf.getTestOnCreate());
+ setTestOnBorrow(conf.getTestOnBorrow());
+ setTestOnReturn(conf.getTestOnReturn());
+ setTestWhileIdle(conf.getTestWhileIdle());
+ setNumTestsPerEvictionRun(conf.getNumTestsPerEvictionRun());
+ setMinEvictableIdleTimeMillis(conf.getMinEvictableIdleTimeMillis());
+
setTimeBetweenEvictionRunsMillis(conf.getTimeBetweenEvictionRunsMillis());
+
setSoftMinEvictableIdleTimeMillis(conf.getSoftMinEvictableIdleTimeMillis());
+ final EvictionPolicy<T> policy = conf.getEvictionPolicy();
+ if (policy == null) {
+ // Use the class name (pre-2.6.0 compatible)
+ setEvictionPolicyClassName(conf.getEvictionPolicyClassName());
+ } else {
+ // Otherwise, use the class (2.6.0 feature)
+ setEvictionPolicy(policy);
+ }
+
setEvictorShutdownTimeoutMillis(conf.getEvictorShutdownTimeoutMillis());
+ }
+
/**
* Returns the maximum amount of time (in milliseconds) the
* <code>borrowObject()</code> method should block before throwing an
@@ -971,7 +994,7 @@ public abstract class BaseGenericObjectP
* Marks the object as returning to the pool.
* @param pooledObject instance to return to the keyed pool
*/
- protected void markReturningState(PooledObject<T> pooledObject) {
+ protected void markReturningState(final PooledObject<T> pooledObject) {
synchronized(pooledObject) {
final PooledObjectState state = pooledObject.getState();
if (state != PooledObjectState.ALLOCATED) {
@@ -1011,7 +1034,7 @@ public abstract class BaseGenericObjectP
*/
private ObjectName jmxRegister(final BaseObjectPoolConfig<T> config,
final String jmxNameBase, String jmxNamePrefix) {
- ObjectName objectName = null;
+ ObjectName newObjectName = null;
final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
int i = 1;
boolean registered = false;
@@ -1030,7 +1053,7 @@ public abstract class BaseGenericObjectP
objName = new ObjectName(base + jmxNamePrefix + i);
}
mbs.registerMBean(this, objName);
- objectName = objName;
+ newObjectName = objName;
registered = true;
} catch (final MalformedObjectNameException e) {
if (BaseObjectPoolConfig.DEFAULT_JMX_NAME_PREFIX.equals(
@@ -1051,7 +1074,7 @@ public abstract class BaseGenericObjectP
registered = true;
}
}
- return objectName;
+ return newObjectName;
}
/**
Modified:
tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/impl/DefaultPooledObject.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/impl/DefaultPooledObject.java?rev=1837737&r1=1837736&r2=1837737&view=diff
==============================================================================
---
tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/impl/DefaultPooledObject.java
(original)
+++
tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/impl/DefaultPooledObject.java
Thu Aug 9 14:51:00 2018
@@ -28,6 +28,7 @@ import org.apache.tomcat.dbcp.pool2.Trac
* the pooled objects.
* <p>
* This class is intended to be thread-safe.
+ * </p>
*
* @param <T> the type of object in the pool
*
@@ -81,10 +82,10 @@ public class DefaultPooledObject<T> impl
@Override
public long getIdleTimeMillis() {
final long elapsed = System.currentTimeMillis() - lastReturnTime;
- // elapsed may be negative if:
- // - another thread updates lastReturnTime during the calculation window
- // - System.currentTimeMillis() is not monotonic (e.g. system time is set
back)
- return elapsed >= 0 ? elapsed : 0;
+ // elapsed may be negative if:
+ // - another thread updates lastReturnTime during the calculation
window
+ // - System.currentTimeMillis() is not monotonic (e.g. system time is
set back)
+ return elapsed >= 0 ? elapsed : 0;
}
@Override
Modified:
tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/impl/GenericKeyedObjectPool.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/impl/GenericKeyedObjectPool.java?rev=1837737&r1=1837736&r2=1837737&view=diff
==============================================================================
---
tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/impl/GenericKeyedObjectPool.java
(original)
+++
tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/impl/GenericKeyedObjectPool.java
Thu Aug 9 14:51:00 2018
@@ -76,8 +76,8 @@ import org.apache.tomcat.dbcp.pool2.Pool
*
* @since 2.0
*/
-public class GenericKeyedObjectPool<K,T> extends BaseGenericObjectPool<T>
- implements KeyedObjectPool<K,T>, GenericKeyedObjectPoolMXBean<K> {
+public class GenericKeyedObjectPool<K, T> extends BaseGenericObjectPool<T>
+ implements KeyedObjectPool<K, T>, GenericKeyedObjectPoolMXBean<K> {
/**
* Create a new <code>GenericKeyedObjectPool</code> using defaults from
@@ -236,30 +236,11 @@ public class GenericKeyedObjectPool<K,T>
* @see GenericKeyedObjectPoolConfig
*/
public void setConfig(final GenericKeyedObjectPoolConfig<T> conf) {
- setLifo(conf.getLifo());
+ super.setConfig(conf);
setMaxIdlePerKey(conf.getMaxIdlePerKey());
setMaxTotalPerKey(conf.getMaxTotalPerKey());
setMaxTotal(conf.getMaxTotal());
setMinIdlePerKey(conf.getMinIdlePerKey());
- setMaxWaitMillis(conf.getMaxWaitMillis());
- setBlockWhenExhausted(conf.getBlockWhenExhausted());
- setTestOnCreate(conf.getTestOnCreate());
- setTestOnBorrow(conf.getTestOnBorrow());
- setTestOnReturn(conf.getTestOnReturn());
- setTestWhileIdle(conf.getTestWhileIdle());
- setNumTestsPerEvictionRun(conf.getNumTestsPerEvictionRun());
- setMinEvictableIdleTimeMillis(conf.getMinEvictableIdleTimeMillis());
-
setSoftMinEvictableIdleTimeMillis(conf.getSoftMinEvictableIdleTimeMillis());
-
setTimeBetweenEvictionRunsMillis(conf.getTimeBetweenEvictionRunsMillis());
- final EvictionPolicy<T> policy = conf.getEvictionPolicy();
- if (policy == null) {
- // Use the class name (pre-2.6.0 compatible)
- setEvictionPolicyClassName(conf.getEvictionPolicyClassName());
- } else {
- // Otherwise, use the class (2.6.0 feature)
- setEvictionPolicy(policy);
- }
-
setEvictorShutdownTimeoutMillis(conf.getEvictorShutdownTimeoutMillis());
}
/**
@@ -478,16 +459,14 @@ public class GenericKeyedObjectPool<K,T>
final long activeTime = p.getActiveTimeMillis();
try {
- if (getTestOnReturn()) {
- if (!factory.validateObject(key, p)) {
- try {
- destroy(key, p, true);
- } catch (final Exception e) {
- swallowException(e);
- }
- whenWaitersAddObject(key, objectDeque.idleObjects);
- return;
+ if (getTestOnReturn() && !factory.validateObject(key, p)) {
+ try {
+ destroy(key, p, true);
+ } catch (final Exception e) {
+ swallowException(e);
}
+ whenWaitersAddObject(key, objectDeque.idleObjects);
+ return;
}
try {
@@ -544,7 +523,7 @@ public class GenericKeyedObjectPool<K,T>
* @param key
* @param idleObjects
*/
- private void whenWaitersAddObject(final K key,
LinkedBlockingDeque<PooledObject<T>> idleObjects) {
+ private void whenWaitersAddObject(final K key, final
LinkedBlockingDeque<PooledObject<T>> idleObjects) {
if (idleObjects.hasTakeWaiters()) {
try {
addObject(key);
Modified:
tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/impl/GenericObjectPool.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/impl/GenericObjectPool.java?rev=1837737&r1=1837736&r2=1837737&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/impl/GenericObjectPool.java
(original)
+++ tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/impl/GenericObjectPool.java
Thu Aug 9 14:51:00 2018
@@ -296,29 +296,10 @@ public class GenericObjectPool<T> extend
* @see GenericObjectPoolConfig
*/
public void setConfig(final GenericObjectPoolConfig<T> conf) {
- setLifo(conf.getLifo());
+ super.setConfig(conf);
setMaxIdle(conf.getMaxIdle());
setMinIdle(conf.getMinIdle());
setMaxTotal(conf.getMaxTotal());
- setMaxWaitMillis(conf.getMaxWaitMillis());
- setBlockWhenExhausted(conf.getBlockWhenExhausted());
- setTestOnCreate(conf.getTestOnCreate());
- setTestOnBorrow(conf.getTestOnBorrow());
- setTestOnReturn(conf.getTestOnReturn());
- setTestWhileIdle(conf.getTestWhileIdle());
- setNumTestsPerEvictionRun(conf.getNumTestsPerEvictionRun());
- setMinEvictableIdleTimeMillis(conf.getMinEvictableIdleTimeMillis());
-
setTimeBetweenEvictionRunsMillis(conf.getTimeBetweenEvictionRunsMillis());
-
setSoftMinEvictableIdleTimeMillis(conf.getSoftMinEvictableIdleTimeMillis());
- final EvictionPolicy<T> policy = conf.getEvictionPolicy();
- if (policy == null) {
- // Use the class name (pre-2.6.0 compatible)
- setEvictionPolicyClassName(conf.getEvictionPolicyClassName());
- } else {
- // Otherwise, use the class (2.6.0 feature)
- setEvictionPolicy(policy);
- }
-
setEvictorShutdownTimeoutMillis(conf.getEvictorShutdownTimeoutMillis());
}
/**
@@ -540,21 +521,19 @@ public class GenericObjectPool<T> extend
final long activeTime = p.getActiveTimeMillis();
- if (getTestOnReturn()) {
- if (!factory.validateObject(p)) {
- try {
- destroy(p);
- } catch (final Exception e) {
- swallowException(e);
- }
- try {
- ensureIdle(1, false);
- } catch (final Exception e) {
- swallowException(e);
- }
- updateStatsReturn(activeTime);
- return;
+ if (getTestOnReturn() && !factory.validateObject(p)) {
+ try {
+ destroy(p);
+ } catch (final Exception e) {
+ swallowException(e);
+ }
+ try {
+ ensureIdle(1, false);
+ } catch (final Exception e) {
+ swallowException(e);
}
+ updateStatsReturn(activeTime);
+ return;
}
try {
@@ -844,6 +823,9 @@ public class GenericObjectPool<T> extend
localMaxTotal = Integer.MAX_VALUE;
}
+ long localStartTimeMillis = System.currentTimeMillis();
+ long localMaxWaitTimeMillis = Math.max(getMaxWaitMillis(), 0);
+
// Flag that indicates if create should:
// - TRUE: call the factory to create an object
// - FALSE: return null
@@ -867,7 +849,7 @@ public class GenericObjectPool<T> extend
// bring the pool to capacity. Those calls might also
// fail so wait until they complete and then re-test if
// the pool is at capacity or not.
- makeObjectCountLock.wait();
+ makeObjectCountLock.wait(localMaxWaitTimeMillis);
}
} else {
// The pool is not at capacity. Create a new object.
@@ -875,6 +857,13 @@ public class GenericObjectPool<T> extend
create = Boolean.TRUE;
}
}
+
+ // Do not block more if maxWaitTimeMillis is set.
+ if (create == null &&
+ (localMaxWaitTimeMillis > 0 &&
+ System.currentTimeMillis() - localStartTimeMillis >=
localMaxWaitTimeMillis)) {
+ create = Boolean.FALSE;
+ }
}
if (!create.booleanValue()) {
Modified:
tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/impl/GenericObjectPoolMXBean.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/impl/GenericObjectPoolMXBean.java?rev=1837737&r1=1837736&r2=1837737&view=diff
==============================================================================
---
tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/impl/GenericObjectPoolMXBean.java
(original)
+++
tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/impl/GenericObjectPoolMXBean.java
Thu Aug 9 14:51:00 2018
@@ -31,149 +31,180 @@ import java.util.Set;
* @since 2.0
*/
public interface GenericObjectPoolMXBean {
+
// Getters for basic configuration settings
+
/**
* See {@link GenericObjectPool#getBlockWhenExhausted()}
* @return See {@link GenericObjectPool#getBlockWhenExhausted()}
*/
boolean getBlockWhenExhausted();
+
/**
* See {@link GenericObjectPool#getLifo()}
* @return See {@link GenericObjectPool#getLifo()}
*/
boolean getFairness();
+
/**
* See {@link GenericObjectPool#getFairness()}
* @return See {@link GenericObjectPool#getFairness()}
*/
boolean getLifo();
+
/**
* See {@link GenericObjectPool#getMaxIdle()}
* @return See {@link GenericObjectPool#getMaxIdle()}
*/
int getMaxIdle();
+
/**
* See {@link GenericObjectPool#getMaxTotal()}
* @return See {@link GenericObjectPool#getMaxTotal()}
*/
int getMaxTotal();
+
/**
* See {@link GenericObjectPool#getMaxWaitMillis()}
* @return See {@link GenericObjectPool#getMaxWaitMillis()}
*/
long getMaxWaitMillis();
+
/**
* See {@link GenericObjectPool#getMinEvictableIdleTimeMillis()}
* @return See {@link GenericObjectPool#getMinEvictableIdleTimeMillis()}
*/
long getMinEvictableIdleTimeMillis();
+
/**
* See {@link GenericObjectPool#getMinIdle()}
* @return See {@link GenericObjectPool#getMinIdle()}
*/
int getMinIdle();
+
/**
* See {@link GenericObjectPool#getNumActive()}
* @return See {@link GenericObjectPool#getNumActive()}
*/
int getNumActive();
+
/**
* See {@link GenericObjectPool#getNumIdle()}
* @return See {@link GenericObjectPool#getNumIdle()}
*/
int getNumIdle();
+
/**
* See {@link GenericObjectPool#getNumTestsPerEvictionRun()}
* @return See {@link GenericObjectPool#getNumTestsPerEvictionRun()}
*/
int getNumTestsPerEvictionRun();
+
/**
* See {@link GenericObjectPool#getTestOnCreate()}
* @return See {@link GenericObjectPool#getTestOnCreate()}
* @since 2.2
*/
boolean getTestOnCreate();
+
/**
* See {@link GenericObjectPool#getTestOnBorrow()}
* @return See {@link GenericObjectPool#getTestOnBorrow()}
*/
boolean getTestOnBorrow();
+
/**
* See {@link GenericObjectPool#getTestOnReturn()}
* @return See {@link GenericObjectPool#getTestOnReturn()}
*/
boolean getTestOnReturn();
+
/**
* See {@link GenericObjectPool#getTestWhileIdle()}
* @return See {@link GenericObjectPool#getTestWhileIdle()}
*/
boolean getTestWhileIdle();
+
/**
* See {@link GenericObjectPool#getTimeBetweenEvictionRunsMillis()}
* @return See {@link GenericObjectPool#getTimeBetweenEvictionRunsMillis()}
*/
long getTimeBetweenEvictionRunsMillis();
+
/**
* See {@link GenericObjectPool#isClosed()}
* @return See {@link GenericObjectPool#isClosed()}
*/
boolean isClosed();
+
// Getters for monitoring attributes
+
/**
* See {@link GenericObjectPool#getBorrowedCount()}
* @return See {@link GenericObjectPool#getBorrowedCount()}
*/
long getBorrowedCount();
+
/**
* See {@link GenericObjectPool#getReturnedCount()}
* @return See {@link GenericObjectPool#getReturnedCount()}
*/
long getReturnedCount();
+
/**
* See {@link GenericObjectPool#getCreatedCount()}
* @return See {@link GenericObjectPool#getCreatedCount()}
*/
long getCreatedCount();
+
/**
* See {@link GenericObjectPool#getDestroyedCount()}
* @return See {@link GenericObjectPool#getDestroyedCount()}
*/
long getDestroyedCount();
+
/**
* See {@link GenericObjectPool#getDestroyedByEvictorCount()}
* @return See {@link GenericObjectPool#getDestroyedByEvictorCount()}
*/
long getDestroyedByEvictorCount();
+
/**
* See {@link GenericObjectPool#getDestroyedByBorrowValidationCount()}
* @return See {@link
GenericObjectPool#getDestroyedByBorrowValidationCount()}
*/
long getDestroyedByBorrowValidationCount();
+
/**
* See {@link GenericObjectPool#getMeanActiveTimeMillis()}
* @return See {@link GenericObjectPool#getMeanActiveTimeMillis()}
*/
long getMeanActiveTimeMillis();
+
/**
* See {@link GenericObjectPool#getMeanIdleTimeMillis()}
* @return See {@link GenericObjectPool#getMeanIdleTimeMillis()}
*/
long getMeanIdleTimeMillis();
+
/**
* See {@link GenericObjectPool#getMeanBorrowWaitTimeMillis()}
* @return See {@link GenericObjectPool#getMeanBorrowWaitTimeMillis()}
*/
long getMeanBorrowWaitTimeMillis();
+
/**
* See {@link GenericObjectPool#getMaxBorrowWaitTimeMillis()}
* @return See {@link GenericObjectPool#getMaxBorrowWaitTimeMillis()}
*/
long getMaxBorrowWaitTimeMillis();
+
/**
* See {@link GenericObjectPool#getCreationStackTrace()}
* @return See {@link GenericObjectPool#getCreationStackTrace()}
*/
String getCreationStackTrace();
+
/**
* See {@link GenericObjectPool#getNumWaiters()}
* @return See {@link GenericObjectPool#getNumWaiters()}
@@ -181,36 +212,43 @@ public interface GenericObjectPoolMXBean
int getNumWaiters();
// Getters for abandoned object removal configuration
+
/**
* See {@link GenericObjectPool#isAbandonedConfig()}
* @return See {@link GenericObjectPool#isAbandonedConfig()}
*/
boolean isAbandonedConfig();
+
/**
* See {@link GenericObjectPool#getLogAbandoned()}
* @return See {@link GenericObjectPool#getLogAbandoned()}
*/
boolean getLogAbandoned();
+
/**
* See {@link GenericObjectPool#getRemoveAbandonedOnBorrow()}
* @return See {@link GenericObjectPool#getRemoveAbandonedOnBorrow()}
*/
boolean getRemoveAbandonedOnBorrow();
+
/**
* See {@link GenericObjectPool#getRemoveAbandonedOnMaintenance()}
* @return See {@link GenericObjectPool#getRemoveAbandonedOnMaintenance()}
*/
boolean getRemoveAbandonedOnMaintenance();
+
/**
* See {@link GenericObjectPool#getRemoveAbandonedTimeout()}
* @return See {@link GenericObjectPool#getRemoveAbandonedTimeout()}
*/
int getRemoveAbandonedTimeout();
+
/**
* See {@link GenericObjectPool#getFactoryType()}
* @return See {@link GenericObjectPool#getFactoryType()}
*/
- public String getFactoryType();
+ String getFactoryType();
+
/**
* See {@link GenericObjectPool#listAllObjects()}
* @return See {@link GenericObjectPool#listAllObjects()}
Modified: tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/impl/PoolImplUtils.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/impl/PoolImplUtils.java?rev=1837737&r1=1837736&r2=1837737&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/impl/PoolImplUtils.java
(original)
+++ tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/impl/PoolImplUtils.java Thu
Aug 9 14:51:00 2018
@@ -120,10 +120,8 @@ class PoolImplUtils {
if (iface instanceof ParameterizedType) {
final ParameterizedType pi = (ParameterizedType) iface;
// Look for the generic interface
- if (pi.getRawType() instanceof Class) {
- if (type.isAssignableFrom((Class<?>) pi.getRawType())) {
- return pi;
- }
+ if (pi.getRawType() instanceof Class &&
type.isAssignableFrom((Class<?>) pi.getRawType())) {
+ return pi;
}
}
}
Modified: tomcat/trunk/webapps/docs/changelog.xml
URL:
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1837737&r1=1837736&r2=1837737&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Thu Aug 9 14:51:00 2018
@@ -240,6 +240,10 @@
<fix>
Fixed spelling. Patch provided by Jimmy Casey via GitHub. (violetagg)
</fix>
+ <update>
+ Update the internal fork of Apache Commons Pool 2 to 3e02523
+ (2018-08-09) to pick up some bug fixes and enhancements. (markt)
+ </update>
</changelog>
</subsection>
</section>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]