This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/10.1.x by this push:
     new f7576994f8 Update Commons Pool to 2.12.1
f7576994f8 is described below

commit f7576994f8b97425ce3902c303ba6a6259240dcd
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Wed Jan 29 18:03:26 2025 +0000

    Update Commons Pool to 2.12.1
---
 MERGE.txt                                          |  2 +-
 .../apache/tomcat/dbcp/pool2/BaseObjectPool.java   |  1 -
 .../apache/tomcat/dbcp/pool2/KeyedObjectPool.java  | 10 +--
 .../dbcp/pool2/KeyedPooledObjectFactory.java       |  8 ---
 java/org/apache/tomcat/dbcp/pool2/ObjectPool.java  |  4 --
 java/org/apache/tomcat/dbcp/pool2/PoolUtils.java   | 36 +++--------
 .../tomcat/dbcp/pool2/PooledObjectFactory.java     |  8 ---
 .../apache/tomcat/dbcp/pool2/UsageTracking.java    |  1 -
 .../tomcat/dbcp/pool2/impl/AbandonedConfig.java    |  2 -
 .../dbcp/pool2/impl/BaseGenericObjectPool.java     | 16 +----
 .../dbcp/pool2/impl/BaseObjectPoolConfig.java      | 32 +++++-----
 .../dbcp/pool2/impl/DefaultEvictionPolicy.java     |  1 -
 .../dbcp/pool2/impl/DefaultPooledObject.java       |  2 -
 .../dbcp/pool2/impl/DefaultPooledObjectInfo.java   |  3 +-
 .../pool2/impl/DefaultPooledObjectInfoMBean.java   |  2 -
 .../tomcat/dbcp/pool2/impl/EvictionTimer.java      | 10 ++-
 .../dbcp/pool2/impl/GenericKeyedObjectPool.java    | 50 ++++-----------
 .../pool2/impl/GenericKeyedObjectPoolConfig.java   | 29 +++++----
 .../tomcat/dbcp/pool2/impl/GenericObjectPool.java  | 73 +++++++++-------------
 .../dbcp/pool2/impl/GenericObjectPoolConfig.java   | 24 +++----
 .../pool2/impl/InterruptibleReentrantLock.java     |  2 +-
 .../dbcp/pool2/impl/LinkedBlockingDeque.java       | 44 +++----------
 .../tomcat/dbcp/pool2/impl/PoolImplUtils.java      |  7 +--
 .../dbcp/pool2/impl/SoftReferenceObjectPool.java   |  5 +-
 .../tomcat/dbcp/pool2/impl/ThrowableCallStack.java | 27 +++++++-
 webapps/docs/changelog.xml                         |  3 +
 26 files changed, 142 insertions(+), 260 deletions(-)

diff --git a/MERGE.txt b/MERGE.txt
index 687b3df6ee..13e6606c8f 100644
--- a/MERGE.txt
+++ b/MERGE.txt
@@ -67,7 +67,7 @@ Unused classes removed
 Sub-tree
 src/main/java/org/apache/commons/pool2
 The SHA1 ID / tag for the most recent commit to be merged to Tomcat is:
-rel/commons-pool-2.12.0 (2023-09-30)
+rel/commons-pool-2.12.1 (2025-01-27)
 
 DBCP2
 No unused code removed
diff --git a/java/org/apache/tomcat/dbcp/pool2/BaseObjectPool.java 
b/java/org/apache/tomcat/dbcp/pool2/BaseObjectPool.java
index b6108c73a7..94ed157997 100644
--- a/java/org/apache/tomcat/dbcp/pool2/BaseObjectPool.java
+++ b/java/org/apache/tomcat/dbcp/pool2/BaseObjectPool.java
@@ -49,7 +49,6 @@ public abstract class BaseObjectPool<T> extends BaseObject 
implements ObjectPool
      * closed.
      *
      * @throws IllegalStateException when this pool has been closed.
-     *
      * @see #isClosed()
      */
     protected final void assertOpen() throws IllegalStateException {
diff --git a/java/org/apache/tomcat/dbcp/pool2/KeyedObjectPool.java 
b/java/org/apache/tomcat/dbcp/pool2/KeyedObjectPool.java
index e0cf3205c4..6d1ba97f45 100644
--- a/java/org/apache/tomcat/dbcp/pool2/KeyedObjectPool.java
+++ b/java/org/apache/tomcat/dbcp/pool2/KeyedObjectPool.java
@@ -49,7 +49,7 @@ import java.util.NoSuchElementException;
  *     }
  * }</pre>
  * <p>
- * {@link KeyedObjectPool} implementations <i>may</i> choose to store at most
+ * {@link KeyedObjectPool} implementations <em>may</em> choose to store at most
  * 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}).
@@ -66,7 +66,6 @@ import java.util.NoSuchElementException;
  * @see KeyedPooledObjectFactory
  * @see ObjectPool
  * @see org.apache.tomcat.dbcp.pool2.impl.GenericKeyedObjectPool 
GenericKeyedObjectPool
- *
  * @since 2.0
  */
 public interface KeyedObjectPool<K, V> extends Closeable {
@@ -78,7 +77,6 @@ public interface KeyedObjectPool<K, V> extends Closeable {
      * "pre-loading" a pool with idle objects (Optional operation).
      *
      * @param key the key a new instance should be added to
-     *
      * @throws Exception
      *              when {@link KeyedPooledObjectFactory#makeObject} fails.
      * @throws IllegalStateException
@@ -161,9 +159,7 @@ public interface KeyedObjectPool<K, V> extends Closeable {
      * </p>
      *
      * @param key the key used to obtain the object
-     *
      * @return an instance from this pool.
-     *
      * @throws IllegalStateException
      *              after {@link #close close} has been called on this pool
      * @throws Exception
@@ -190,7 +186,6 @@ public interface KeyedObjectPool<K, V> extends Closeable {
      * the given {@code key} (optional operation).
      *
      * @param key the key to clear
-     *
      * @throws UnsupportedOperationException when this implementation doesn't
      *                                       support the operation
      *
@@ -280,7 +275,6 @@ public interface KeyedObjectPool<K, V> extends Closeable {
      *
      * @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
      */
     void invalidateObject(K key, V obj) throws Exception;
@@ -303,7 +297,6 @@ public interface KeyedObjectPool<K, V> extends Closeable {
      * @param key the key used to obtain the object
      * @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
      * @since 2.9.0
      */
@@ -320,7 +313,6 @@ public interface KeyedObjectPool<K, V> extends Closeable {
      *
      * @param key the key used to obtain the object
      * @param obj a {@link #borrowObject borrowed} instance to be returned.
-     *
      * @throws IllegalStateException
      *              if an attempt is made to return an object to the pool that
      *              is in any state other than allocated (i.e. borrowed).
diff --git a/java/org/apache/tomcat/dbcp/pool2/KeyedPooledObjectFactory.java 
b/java/org/apache/tomcat/dbcp/pool2/KeyedPooledObjectFactory.java
index 35a9842398..9c0a71c5a9 100644
--- a/java/org/apache/tomcat/dbcp/pool2/KeyedPooledObjectFactory.java
+++ b/java/org/apache/tomcat/dbcp/pool2/KeyedPooledObjectFactory.java
@@ -67,10 +67,8 @@ package org.apache.tomcat.dbcp.pool2;
  * </p>
  *
  * @see KeyedObjectPool
- *
  * @param <K> The type of keys managed by this factory.
  * @param <V> Type of element managed by this factory.
- *
  * @since 2.0
  */
 public interface KeyedPooledObjectFactory<K, V> {
@@ -80,7 +78,6 @@ public interface KeyedPooledObjectFactory<K, V> {
      *
      * @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},
      *    this exception may be swallowed by the pool.
      *
@@ -102,7 +99,6 @@ public interface KeyedPooledObjectFactory<K, V> {
      *
      * @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
      *    the pool implementation.
      *
@@ -117,7 +113,6 @@ public interface KeyedPooledObjectFactory<K, V> {
      * @param key the key used when selecting the instance
      * @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
      *    the pool implementation.
      *
@@ -136,7 +131,6 @@ public interface KeyedPooledObjectFactory<K, V> {
      * wrap it in a {@link PooledObject} to be managed by the pool.
      *
      * @param key the key used when constructing the object
-     *
      * @return a {@code PooledObject} wrapping an instance that can
      * be served by the pool.
      *
@@ -150,7 +144,6 @@ public interface KeyedPooledObjectFactory<K, V> {
      *
      * @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},
      *    this exception may be swallowed by the pool.
      *
@@ -163,7 +156,6 @@ public interface KeyedPooledObjectFactory<K, V> {
      *
      * @param key the key used when selecting the object
      * @param p a {@code PooledObject} wrapping the instance to be validated
-     *
      * @return {@code false} if {@code obj} is not valid and should
      *         be dropped from the pool, {@code true} otherwise.
      */
diff --git a/java/org/apache/tomcat/dbcp/pool2/ObjectPool.java 
b/java/org/apache/tomcat/dbcp/pool2/ObjectPool.java
index 32b503fc53..848957f0f0 100644
--- a/java/org/apache/tomcat/dbcp/pool2/ObjectPool.java
+++ b/java/org/apache/tomcat/dbcp/pool2/ObjectPool.java
@@ -54,7 +54,6 @@ import java.util.NoSuchElementException;
  * @see PooledObjectFactory
  * @see KeyedObjectPool
  * @see BaseObjectPool
- *
  * @since 2.0
  */
 public interface ObjectPool<T> extends Closeable {
@@ -110,7 +109,6 @@ public interface ObjectPool<T> extends Closeable {
      * </p>
      *
      * @return an instance from this pool.
-     *
      * @throws IllegalStateException
      *              after {@link #close close} has been called on this pool.
      * @throws Exception
@@ -176,7 +174,6 @@ public interface ObjectPool<T> extends Closeable {
      * </p>
      *
      * @param obj a {@link #borrowObject borrowed} instance to be disposed.
-     *
      * @throws Exception if the instance cannot be invalidated
      */
     void invalidateObject(T obj) throws Exception;
@@ -209,7 +206,6 @@ public interface ObjectPool<T> extends Closeable {
      * a related method as defined in an implementation or sub-interface.
      *
      * @param obj a {@link #borrowObject borrowed} instance to be returned.
-     *
      * @throws IllegalStateException
      *              if an attempt is made to return an object to the pool that
      *              is in any state other than allocated (i.e. borrowed).
diff --git a/java/org/apache/tomcat/dbcp/pool2/PoolUtils.java 
b/java/org/apache/tomcat/dbcp/pool2/PoolUtils.java
index 7c3f35d8ae..be6b52d374 100644
--- a/java/org/apache/tomcat/dbcp/pool2/PoolUtils.java
+++ b/java/org/apache/tomcat/dbcp/pool2/PoolUtils.java
@@ -326,9 +326,8 @@ public final class PoolUtils {
      * may be invalidated instead of being added to idle capacity.
      *
      * @param <T> type of objects in the pool
-     *
      */
-    private static class ErodingObjectPool<T> implements ObjectPool<T> {
+    private static final class ErodingObjectPool<T> implements ObjectPool<T> {
 
         /** Underlying object pool */
         private final ObjectPool<T> pool;
@@ -596,7 +595,6 @@ public final class PoolUtils {
      * as the pool's minIdle setting.
      *
      * @param <T> type of objects in the pool
-     *
      */
     private static final class ObjectPoolMinIdleTimerTask<T> extends TimerTask 
{
 
@@ -666,7 +664,7 @@ public final class PoolUtils {
      * A synchronized (thread-safe) KeyedObjectPool backed by the specified
      * KeyedObjectPool.
      * <p>
-     * <b>Note:</b> This should not be used on pool implementations that 
already
+     * <strong>Note:</strong> This should not be used on pool implementations 
that already
      * provide proper synchronization such as the pools provided in the Commons
      * Pool library. Wrapping a pool that {@link #wait() waits} for poolable
      * objects to be returned before allowing another one to be borrowed with
@@ -897,7 +895,7 @@ public final class PoolUtils {
      * KeyedPooledObjectFactory and synchronizes access to the wrapped factory
      * methods.
      * <p>
-     * <b>Note:</b> This should not be used on pool implementations that 
already
+     * <strong>Note:</strong> This should not be used on pool implementations 
that already
      * provide proper synchronization such as the pools provided in the Commons
      * Pool library.
      * </p>
@@ -1012,7 +1010,7 @@ public final class PoolUtils {
      * A synchronized (thread-safe) ObjectPool backed by the specified
      * ObjectPool.
      * <p>
-     * <b>Note:</b> This should not be used on pool implementations that 
already
+     * <strong>Note:</strong> This should not be used on pool implementations 
that already
      * provide proper synchronization such as the pools provided in the Commons
      * Pool library. Wrapping a pool that {@link #wait() waits} for poolable
      * objects to be returned before allowing another one to be borrowed with
@@ -1021,7 +1019,6 @@ public final class PoolUtils {
      * </p>
      *
      * @param <T> type of objects in the pool
-     *
      */
     private static final class SynchronizedObjectPool<T> implements 
ObjectPool<T> {
 
@@ -1031,7 +1028,7 @@ public final class PoolUtils {
          */
         private final ReentrantReadWriteLock readWriteLock = new 
ReentrantReadWriteLock();
 
-        /** the underlying object pool */
+        /** The underlying object pool */
         private final ObjectPool<T> pool;
 
         /**
@@ -1187,7 +1184,7 @@ public final class PoolUtils {
      * PooledObjectFactory and synchronizes access to the wrapped factory
      * methods.
      * <p>
-     * <b>Note:</b> This should not be used on pool implementations that 
already
+     * <strong>Note:</strong> This should not be used on pool implementations 
that already
      * provide proper synchronization such as the pools provided in the Commons
      * Pool library.
      * </p>
@@ -1335,7 +1332,6 @@ public final class PoolUtils {
      *            keyedPool, see {@link Timer#schedule(TimerTask, long, long)}.
      * @param <K> the type of the pool key
      * @param <V> the type of pool entries
-     *
      * @return a {@link Map} of key and {@link TimerTask} pairs that will
      *         periodically check the pools idle object count.
      * @throws IllegalArgumentException
@@ -1353,10 +1349,7 @@ public final class PoolUtils {
             throw new IllegalArgumentException(MSG_NULL_KEYS);
         }
         final Map<K, TimerTask> tasks = new HashMap<>(keys.size());
-        for (K key : keys) {
-            final TimerTask task = checkMinIdle(keyedPool, key, minIdle, 
periodMillis);
-            tasks.put(key, task);
-        }
+        keys.forEach(key -> tasks.put(key, checkMinIdle(keyedPool, key, 
minIdle, periodMillis)));
         return tasks;
     }
 
@@ -1378,7 +1371,6 @@ public final class PoolUtils {
      *            keyedPool, see {@link Timer#schedule(TimerTask, long, long)}.
      * @param <K> the type of the pool key
      * @param <V> the type of pool entries
-     *
      * @return the {@link TimerTask} that will periodically check the pools 
idle
      *         object count.
      * @throws IllegalArgumentException
@@ -1419,7 +1411,6 @@ public final class PoolUtils {
      *            the frequency in milliseconds to check the number of idle 
objects in a pool,
      *            see {@link Timer#schedule(TimerTask, long, long)}.
      * @param <T> the type of objects in the pool
-     *
      * @return the {@link TimerTask} that will periodically check the pools 
idle
      *         object count.
      * @throws IllegalArgumentException
@@ -1476,7 +1467,6 @@ public final class PoolUtils {
      *            count when possible.
      * @param <K> the type of the pool key
      * @param <V> the type of pool entries
-     *
      * @throws IllegalArgumentException
      *             when {@code keyedPool} is {@code null}.
      * @return a pool that adaptively decreases its size when idle objects are
@@ -1511,7 +1501,6 @@ public final class PoolUtils {
      *            shrinks less aggressively.
      * @param <K> the type of the pool key
      * @param <V> the type of pool entries
-     *
      * @throws IllegalArgumentException
      *             when {@code keyedPool} is {@code null} or when {@code 
factor}
      *             is not positive.
@@ -1554,7 +1543,6 @@ public final class PoolUtils {
      *            when true, each key is treated independently.
      * @param <K> the type of the pool key
      * @param <V> the type of pool entries
-     *
      * @throws IllegalArgumentException
      *             when {@code keyedPool} is {@code null} or when {@code 
factor}
      *             is not positive.
@@ -1589,7 +1577,6 @@ public final class PoolUtils {
      *            the ObjectPool to be decorated so it shrinks its idle count
      *            when possible.
      * @param <T> the type of objects in the pool
-     *
      * @throws IllegalArgumentException
      *             when {@code pool} is {@code null}.
      * @return a pool that adaptively decreases its size when idle objects are
@@ -1622,7 +1609,6 @@ public final class PoolUtils {
      *            shrinks more aggressively. If 1 &lt; factor then the pool
      *            shrinks less aggressively.
      * @param <T> the type of objects in the pool
-     *
      * @throws IllegalArgumentException
      *             when {@code pool} is {@code null} or when {@code factor} is
      *             not positive.
@@ -1663,7 +1649,6 @@ public final class PoolUtils {
      *            the number of idle objects to add for each {@code key}.
      * @param <K> the type of the pool key
      * @param <V> the type of pool entries
-     *
      * @throws Exception
      *             when {@link KeyedObjectPool#addObject(Object)} fails.
      * @throws IllegalArgumentException
@@ -1694,7 +1679,6 @@ public final class PoolUtils {
      *            the number of idle objects to add for {@code key}.
      * @param <K> the type of the pool key
      * @param <V> the type of pool entries
-     *
      * @throws Exception
      *             when {@link KeyedObjectPool#addObject(Object)} fails.
      * @throws IllegalArgumentException
@@ -1720,7 +1704,6 @@ public final class PoolUtils {
      * @param count
      *            the number of idle objects to add.
      * @param <T> the type of objects in the pool
-     *
      * @throws Exception
      *             when {@link ObjectPool#addObject()} fails.
      * @throws IllegalArgumentException
@@ -1756,7 +1739,7 @@ public final class PoolUtils {
      * Returns a synchronized (thread-safe) KeyedObjectPool backed by the
      * specified KeyedObjectPool.
      * <p>
-     * <b>Note:</b> This should not be used on pool implementations that 
already
+     * <strong>Note:</strong> This should not be used on pool implementations 
that already
      * provide proper synchronization such as the pools provided in the Commons
      * Pool library. Wrapping a pool that {@link #wait() waits} for poolable
      * objects to be returned before allowing another one to be borrowed with
@@ -1769,7 +1752,6 @@ public final class PoolUtils {
      *            KeyedObjectPool.
      * @param <K> the type of the pool key
      * @param <V> the type of pool entries
-     *
      * @return a synchronized view of the specified KeyedObjectPool.
      */
     public static <K, V> KeyedObjectPool<K, V> synchronizedPool(final 
KeyedObjectPool<K, V> keyedPool) {
@@ -1789,7 +1771,7 @@ public final class PoolUtils {
      * Returns a synchronized (thread-safe) ObjectPool backed by the specified
      * ObjectPool.
      * <p>
-     * <b>Note:</b> This should not be used on pool implementations that 
already
+     * <strong>Note:</strong> This should not be used on pool implementations 
that already
      * provide proper synchronization such as the pools provided in the Commons
      * Pool library. Wrapping a pool that {@link #wait() waits} for poolable
      * objects to be returned before allowing another one to be borrowed with
diff --git a/java/org/apache/tomcat/dbcp/pool2/PooledObjectFactory.java 
b/java/org/apache/tomcat/dbcp/pool2/PooledObjectFactory.java
index 96d020df82..5c5a662039 100644
--- a/java/org/apache/tomcat/dbcp/pool2/PooledObjectFactory.java
+++ b/java/org/apache/tomcat/dbcp/pool2/PooledObjectFactory.java
@@ -65,9 +65,7 @@ package org.apache.tomcat.dbcp.pool2;
  * </p>
  *
  * @param <T> Type of element managed in this factory.
- *
  * @see ObjectPool
- *
  * @since 2.0
  */
 public interface PooledObjectFactory<T> {
@@ -76,7 +74,6 @@ public interface PooledObjectFactory<T> {
    * Reinitializes an instance to be returned by the pool.
    *
    * @param p a {@code PooledObject} wrapping the instance to be activated
-   *
    * @throws Exception if there is a problem activating {@code obj},
    *    this exception may be swallowed by the pool.
    *
@@ -98,7 +95,6 @@ public interface PooledObjectFactory<T> {
    * </p>
    *
    * @param p a {@code PooledObject} wrapping the instance to be destroyed
-   *
    * @throws Exception should be avoided as it may be swallowed by
    *    the pool implementation.
    *
@@ -113,7 +109,6 @@ public interface PooledObjectFactory<T> {
    *
    * @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
    *    the pool implementation.
    *
@@ -132,7 +127,6 @@ public interface PooledObjectFactory<T> {
    * {@link PooledObject} to be managed by the pool.
    *
    * @return a {@code PooledObject} wrapping an instance that can be served by 
the pool, not null.
-   *
    * @throws Exception if there is a problem creating a new instance,
    *    this will be propagated to the code requesting an object.
    */
@@ -142,7 +136,6 @@ public interface PooledObjectFactory<T> {
    * Uninitializes an instance to be returned to the idle object pool.
    *
    * @param p a {@code PooledObject} wrapping the instance to be passivated
-   *
    * @throws Exception if there is a problem passivating {@code obj},
    *    this exception may be swallowed by the pool.
    *
@@ -154,7 +147,6 @@ public interface PooledObjectFactory<T> {
    * Ensures that the instance is safe to be returned by the pool.
    *
    * @param p a {@code PooledObject} wrapping the instance to be validated
-   *
    * @return {@code false} if {@code obj} is not valid and should
    *         be dropped from the pool, {@code true} otherwise.
    */
diff --git a/java/org/apache/tomcat/dbcp/pool2/UsageTracking.java 
b/java/org/apache/tomcat/dbcp/pool2/UsageTracking.java
index 9d498639c2..6b86754d98 100644
--- a/java/org/apache/tomcat/dbcp/pool2/UsageTracking.java
+++ b/java/org/apache/tomcat/dbcp/pool2/UsageTracking.java
@@ -22,7 +22,6 @@ package org.apache.tomcat.dbcp.pool2;
  * more informed decisions and reporting to be made regarding abandoned 
objects.
  *
  * @param <T> The type of object provided by the pool.
- *
  * @since 2.0
  */
 public interface UsageTracking<T> {
diff --git a/java/org/apache/tomcat/dbcp/pool2/impl/AbandonedConfig.java 
b/java/org/apache/tomcat/dbcp/pool2/impl/AbandonedConfig.java
index 7f4fc251bb..92797c8b45 100644
--- a/java/org/apache/tomcat/dbcp/pool2/impl/AbandonedConfig.java
+++ b/java/org/apache/tomcat/dbcp/pool2/impl/AbandonedConfig.java
@@ -123,7 +123,6 @@ public class AbandonedConfig {
      *
      * @return boolean true if stack trace logging is turned on for abandoned
      * objects
-     *
      */
     public boolean getLogAbandoned() {
         return this.logAbandoned;
@@ -240,7 +239,6 @@ public class AbandonedConfig {
      *
      * @param logAbandoned true turns on abandoned stack trace logging
      * @see #getLogAbandoned()
-     *
      */
     public void setLogAbandoned(final boolean logAbandoned) {
         this.logAbandoned = logAbandoned;
diff --git a/java/org/apache/tomcat/dbcp/pool2/impl/BaseGenericObjectPool.java 
b/java/org/apache/tomcat/dbcp/pool2/impl/BaseGenericObjectPool.java
index 25f30d0135..2e1599fd52 100644
--- a/java/org/apache/tomcat/dbcp/pool2/impl/BaseGenericObjectPool.java
+++ b/java/org/apache/tomcat/dbcp/pool2/impl/BaseGenericObjectPool.java
@@ -65,7 +65,7 @@ public abstract class BaseGenericObjectPool<T> extends 
BaseObject implements Aut
     /**
      * The idle object eviction iterator. Holds a reference to the idle 
objects.
      */
-    class EvictionIterator implements Iterator<PooledObject<T>> {
+    final class EvictionIterator implements Iterator<PooledObject<T>> {
 
         private final Deque<PooledObject<T>> idleObjects;
         private final Iterator<PooledObject<T>> idleObjectIterator;
@@ -117,7 +117,7 @@ public abstract class BaseGenericObjectPool<T> extends 
BaseObject implements Aut
      *
      * @see GenericKeyedObjectPool#setTimeBetweenEvictionRunsMillis
      */
-    class Evictor implements Runnable {
+    final class Evictor implements Runnable {
 
         private ScheduledFuture<?> scheduledFuture;
 
@@ -249,7 +249,7 @@ public abstract class BaseGenericObjectPool<T> extends 
BaseObject implements Aut
      * Maintains a cache of values for a single metric and reports
      * statistics on the cached values.
      */
-    private static class StatsStore {
+    private static final class StatsStore {
 
         private static final int NONE = -1;
         private final AtomicLong[] values;
@@ -579,7 +579,6 @@ public abstract class BaseGenericObjectPool<T> extends 
BaseObject implements Aut
      * will be run.
      *
      * @return number of milliseconds to sleep between evictor runs
-     *
      * @see #setTimeBetweenEvictionRuns
      * @since 2.11.0
      */
@@ -603,7 +602,6 @@ public abstract class BaseGenericObjectPool<T> extends 
BaseObject implements Aut
      * used by this pool.
      *
      * @return  The fully qualified class name of the {@link EvictionPolicy}
-     *
      * @see #setEvictionPolicyClassName(String)
      */
     public final String getEvictionPolicyClassName() {
@@ -935,7 +933,6 @@ public abstract class BaseGenericObjectPool<T> extends 
BaseObject implements Aut
      * tested per run.
      *
      * @return max number of objects to examine during each evictor run
-     *
      * @see #setNumTestsPerEvictionRun
      * @see #setTimeBetweenEvictionRunsMillis
      */
@@ -1150,7 +1147,6 @@ public abstract class BaseGenericObjectPool<T> extends 
BaseObject implements Aut
      *         being returned from the {@code borrowObject()} method
      *
      * @see #setTestOnCreate
-     *
      * @since 2.2
      */
     public final boolean getTestOnCreate() {
@@ -1182,7 +1178,6 @@ public abstract class BaseGenericObjectPool<T> extends 
BaseObject implements Aut
      * the pool and destroyed.
      *
      * @return {@code true} if objects will be validated by the evictor
-     *
      * @see #setTestWhileIdle
      * @see #setTimeBetweenEvictionRunsMillis
      */
@@ -1196,7 +1191,6 @@ public abstract class BaseGenericObjectPool<T> extends 
BaseObject implements Aut
      * will be run.
      *
      * @return number of milliseconds to sleep between evictor runs
-     *
      * @see #setTimeBetweenEvictionRuns
      * @since 2.10.0
      * @deprecated {@link #getDurationBetweenEvictionRuns()}.
@@ -1212,7 +1206,6 @@ public abstract class BaseGenericObjectPool<T> extends 
BaseObject implements Aut
      * will be run.
      *
      * @return number of milliseconds to sleep between evictor runs
-     *
      * @see #setTimeBetweenEvictionRunsMillis
      * @deprecated Use {@link #getDurationBetweenEvictionRuns()}.
      */
@@ -1333,7 +1326,6 @@ public abstract class BaseGenericObjectPool<T> extends 
BaseObject implements Aut
      * Sets the abandoned object removal configuration.
      *
      * @param abandonedConfig the new configuration to use. This is used by 
value.
-     *
      * @see AbandonedConfig
      * @since 2.11.0
      */
@@ -1833,7 +1825,6 @@ public abstract class BaseGenericObjectPool<T> extends 
BaseObject implements Aut
      *                      {@code borrowObject()} method
      *
      * @see #getTestOnCreate
-     *
      * @since 2.2
      */
     public final void setTestOnCreate(final boolean testOnCreate) {
@@ -2078,5 +2069,4 @@ public abstract class BaseGenericObjectPool<T> extends 
BaseObject implements Aut
         activeTimes.add(activeTime);
     }
 
-
 }
diff --git a/java/org/apache/tomcat/dbcp/pool2/impl/BaseObjectPoolConfig.java 
b/java/org/apache/tomcat/dbcp/pool2/impl/BaseObjectPoolConfig.java
index cd40a8bc51..38d7aa523e 100644
--- a/java/org/apache/tomcat/dbcp/pool2/impl/BaseObjectPoolConfig.java
+++ b/java/org/apache/tomcat/dbcp/pool2/impl/BaseObjectPoolConfig.java
@@ -33,7 +33,7 @@ import org.apache.tomcat.dbcp.pool2.BaseObject;
 public abstract class BaseObjectPoolConfig<T> extends BaseObject implements 
Cloneable {
 
     /**
-     * The default value for the {@code lifo} configuration attribute.
+     * The default value for the {@code lifo} configuration attribute: 
{@value}.
      *
      * @see GenericObjectPool#getLifo()
      * @see GenericKeyedObjectPool#getLifo()
@@ -41,7 +41,7 @@ public abstract class BaseObjectPoolConfig<T> extends 
BaseObject implements Clon
     public static final boolean DEFAULT_LIFO = true;
 
     /**
-     * The default value for the {@code fairness} configuration attribute.
+     * The default value for the {@code fairness} configuration attribute: 
{@value}.
      *
      * @see GenericObjectPool#getFairness()
      * @see GenericKeyedObjectPool#getFairness()
@@ -49,7 +49,7 @@ public abstract class BaseObjectPoolConfig<T> extends 
BaseObject implements Clon
     public static final boolean DEFAULT_FAIRNESS = false;
 
     /**
-     * The default value for the {@code maxWait} configuration attribute.
+     * The default value for the {@code maxWait} configuration attribute: 
{@value}.
      *
      * @see GenericObjectPool#getMaxWaitDuration()
      * @see GenericKeyedObjectPool#getMaxWaitDuration()
@@ -68,7 +68,7 @@ public abstract class BaseObjectPoolConfig<T> extends 
BaseObject implements Clon
     public static final Duration DEFAULT_MAX_WAIT = 
Duration.ofMillis(DEFAULT_MAX_WAIT_MILLIS);
 
     /**
-     * The default value for the {@code minEvictableIdleDuration} 
configuration attribute.
+     * The default value for the {@code minEvictableIdleDuration} 
configuration attribute: {@value}.
      *
      * @see GenericObjectPool#getMinEvictableIdleDuration()
      * @see GenericKeyedObjectPool#getMinEvictableIdleDuration()
@@ -98,7 +98,7 @@ public abstract class BaseObjectPoolConfig<T> extends 
BaseObject implements Clon
     public static final Duration DEFAULT_MIN_EVICTABLE_IDLE_TIME = 
Duration.ofMillis(DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
 
     /**
-     * The default value for the {@code softMinEvictableIdleTime} 
configuration attribute.
+     * The default value for the {@code softMinEvictableIdleTime} 
configuration attribute: {@value}.
      *
      * @see GenericObjectPool#getSoftMinEvictableIdleDuration()
      * @see GenericKeyedObjectPool#getSoftMinEvictableIdleDuration()
@@ -128,7 +128,7 @@ public abstract class BaseObjectPoolConfig<T> extends 
BaseObject implements Clon
     public static final Duration DEFAULT_SOFT_MIN_EVICTABLE_IDLE_DURATION = 
Duration.ofMillis(DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
 
     /**
-     * The default value for {@code evictorShutdownTimeout} configuration 
attribute.
+     * The default value for {@code evictorShutdownTimeout} configuration 
attribute: {@value}.
      *
      * @see GenericObjectPool#getEvictorShutdownTimeoutDuration()
      * @see GenericKeyedObjectPool#getEvictorShutdownTimeoutDuration()
@@ -147,7 +147,7 @@ public abstract class BaseObjectPoolConfig<T> extends 
BaseObject implements Clon
     public static final Duration DEFAULT_EVICTOR_SHUTDOWN_TIMEOUT = 
Duration.ofMillis(DEFAULT_EVICTOR_SHUTDOWN_TIMEOUT_MILLIS);
 
     /**
-     * The default value for the {@code numTestsPerEvictionRun} configuration 
attribute.
+     * The default value for the {@code numTestsPerEvictionRun} configuration 
attribute: {@value}.
      *
      * @see GenericObjectPool#getNumTestsPerEvictionRun()
      * @see GenericKeyedObjectPool#getNumTestsPerEvictionRun()
@@ -155,17 +155,16 @@ public abstract class BaseObjectPoolConfig<T> extends 
BaseObject implements Clon
     public static final int DEFAULT_NUM_TESTS_PER_EVICTION_RUN = 3;
 
     /**
-     * The default value for the {@code testOnCreate} configuration attribute.
+     * The default value for the {@code testOnCreate} configuration attribute: 
{@value}.
      *
      * @see GenericObjectPool#getTestOnCreate()
      * @see GenericKeyedObjectPool#getTestOnCreate()
-     *
      * @since 2.2
      */
     public static final boolean DEFAULT_TEST_ON_CREATE = false;
 
     /**
-     * The default value for the {@code testOnBorrow} configuration attribute.
+     * The default value for the {@code testOnBorrow} configuration attribute: 
{@value}.
      *
      * @see GenericObjectPool#getTestOnBorrow()
      * @see GenericKeyedObjectPool#getTestOnBorrow()
@@ -173,7 +172,7 @@ public abstract class BaseObjectPoolConfig<T> extends 
BaseObject implements Clon
     public static final boolean DEFAULT_TEST_ON_BORROW = false;
 
     /**
-     * The default value for the {@code testOnReturn} configuration attribute.
+     * The default value for the {@code testOnReturn} configuration attribute: 
{@value}.
      *
      * @see GenericObjectPool#getTestOnReturn()
      * @see GenericKeyedObjectPool#getTestOnReturn()
@@ -181,7 +180,7 @@ public abstract class BaseObjectPoolConfig<T> extends 
BaseObject implements Clon
     public static final boolean DEFAULT_TEST_ON_RETURN = false;
 
     /**
-     * The default value for the {@code testWhileIdle} configuration attribute.
+     * The default value for the {@code testWhileIdle} configuration 
attribute: {@value}.
      *
      * @see GenericObjectPool#getTestWhileIdle()
      * @see GenericKeyedObjectPool#getTestWhileIdle()
@@ -189,7 +188,7 @@ public abstract class BaseObjectPoolConfig<T> extends 
BaseObject implements Clon
     public static final boolean DEFAULT_TEST_WHILE_IDLE = false;
 
     /**
-     * The default value for the {@code timeBetweenEvictionRuns} configuration 
attribute.
+     * The default value for the {@code timeBetweenEvictionRuns} configuration 
attribute: {@value}.
      *
      * @see GenericObjectPool#getDurationBetweenEvictionRuns()
      * @see GenericKeyedObjectPool#getDurationBetweenEvictionRuns()
@@ -218,7 +217,7 @@ public abstract class BaseObjectPoolConfig<T> extends 
BaseObject implements Clon
     public static final Duration DEFAULT_TIME_BETWEEN_EVICTION_RUNS = 
Duration.ofMillis(DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS);
 
     /**
-     * The default value for the {@code blockWhenExhausted} configuration 
attribute.
+     * The default value for the {@code blockWhenExhausted} configuration 
attribute: {@value}.
      *
      * @see GenericObjectPool#getBlockWhenExhausted()
      * @see GenericKeyedObjectPool#getBlockWhenExhausted()
@@ -226,12 +225,12 @@ public abstract class BaseObjectPoolConfig<T> extends 
BaseObject implements Clon
     public static final boolean DEFAULT_BLOCK_WHEN_EXHAUSTED = true;
 
     /**
-     * The default value for enabling JMX for pools created with a 
configuration instance.
+     * The default value for enabling JMX for pools created with a 
configuration instance: {@value}.
      */
     public static final boolean DEFAULT_JMX_ENABLE = true;
 
     /**
-     * The default value for the prefix used to name JMX enabled pools created 
with a configuration instance.
+     * The default value for the prefix used to name JMX enabled pools created 
with a configuration instance: {@value}.
      *
      * @see GenericObjectPool#getJmxName()
      * @see GenericKeyedObjectPool#getJmxName()
@@ -420,7 +419,6 @@ public abstract class BaseObjectPoolConfig<T> extends 
BaseObject implements Clon
      * Gets the value for the {@code lifo} configuration attribute for pools 
created with this configuration instance.
      *
      * @return The current setting of {@code lifo} for this configuration 
instance
-     *
      * @see GenericObjectPool#getLifo()
      * @see GenericKeyedObjectPool#getLifo()
      */
diff --git a/java/org/apache/tomcat/dbcp/pool2/impl/DefaultEvictionPolicy.java 
b/java/org/apache/tomcat/dbcp/pool2/impl/DefaultEvictionPolicy.java
index 0255b6a75c..ffe607242e 100644
--- a/java/org/apache/tomcat/dbcp/pool2/impl/DefaultEvictionPolicy.java
+++ b/java/org/apache/tomcat/dbcp/pool2/impl/DefaultEvictionPolicy.java
@@ -38,7 +38,6 @@ import org.apache.tomcat.dbcp.pool2.PooledObject;
  * </p>
  *
  * @param <T> the type of objects in the pool.
- *
  * @since 2.0
  */
 public class DefaultEvictionPolicy<T> implements EvictionPolicy<T> {
diff --git a/java/org/apache/tomcat/dbcp/pool2/impl/DefaultPooledObject.java 
b/java/org/apache/tomcat/dbcp/pool2/impl/DefaultPooledObject.java
index 348b51951c..5c0c3af543 100644
--- a/java/org/apache/tomcat/dbcp/pool2/impl/DefaultPooledObject.java
+++ b/java/org/apache/tomcat/dbcp/pool2/impl/DefaultPooledObject.java
@@ -34,7 +34,6 @@ import org.apache.tomcat.dbcp.pool2.TrackedUse;
  * </p>
  *
  * @param <T> the type of object in the pool
- *
  * @since 2.0
  */
 public class DefaultPooledObject<T> implements PooledObject<T> {
@@ -339,5 +338,4 @@ public class DefaultPooledObject<T> implements 
PooledObject<T> {
         usedBy.fillInStackTrace();
     }
 
-
 }
diff --git 
a/java/org/apache/tomcat/dbcp/pool2/impl/DefaultPooledObjectInfo.java 
b/java/org/apache/tomcat/dbcp/pool2/impl/DefaultPooledObjectInfo.java
index 2d7b0e35a2..30854e2fad 100644
--- a/java/org/apache/tomcat/dbcp/pool2/impl/DefaultPooledObjectInfo.java
+++ b/java/org/apache/tomcat/dbcp/pool2/impl/DefaultPooledObjectInfo.java
@@ -24,7 +24,7 @@ import java.util.Objects;
 import org.apache.tomcat.dbcp.pool2.PooledObject;
 
 /**
- * Implementation of object that is used to provide information on pooled
+ * Implements providing information on pooled
  * objects via JMX.
  *
  * @since 2.0
@@ -65,7 +65,6 @@ public class DefaultPooledObjectInfo implements 
DefaultPooledObjectInfoMBean {
         return pooledObject.getLastBorrowInstant().toEpochMilli();
     }
 
-
     @Override
     public String getLastBorrowTimeFormatted() {
         return getTimeMillisFormatted(getLastBorrowTime());
diff --git 
a/java/org/apache/tomcat/dbcp/pool2/impl/DefaultPooledObjectInfoMBean.java 
b/java/org/apache/tomcat/dbcp/pool2/impl/DefaultPooledObjectInfoMBean.java
index fb026de1c8..3e8ad6ea04 100644
--- a/java/org/apache/tomcat/dbcp/pool2/impl/DefaultPooledObjectInfoMBean.java
+++ b/java/org/apache/tomcat/dbcp/pool2/impl/DefaultPooledObjectInfoMBean.java
@@ -90,7 +90,6 @@ public interface DefaultPooledObjectInfoMBean {
      * Gets a String form of the wrapper for debug purposes. The format is not 
fixed and may change at any time.
      *
      * @return A string representation of the pooled object.
-     *
      * @see Object#toString()
      */
     String getPooledObjectToString();
@@ -99,7 +98,6 @@ public interface DefaultPooledObjectInfoMBean {
      * Gets the name of the class of the pooled object.
      *
      * @return The pooled object's class name.
-     *
      * @see Class#getName()
      */
     String getPooledObjectType();
diff --git a/java/org/apache/tomcat/dbcp/pool2/impl/EvictionTimer.java 
b/java/org/apache/tomcat/dbcp/pool2/impl/EvictionTimer.java
index 3e2be3108b..58fa30954d 100644
--- a/java/org/apache/tomcat/dbcp/pool2/impl/EvictionTimer.java
+++ b/java/org/apache/tomcat/dbcp/pool2/impl/EvictionTimer.java
@@ -27,7 +27,6 @@ import java.util.concurrent.ScheduledThreadPoolExecutor;
 import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.TimeUnit;
 
-
 /**
  * Provides a shared idle object eviction timer for all pools.
  * <p>
@@ -46,12 +45,12 @@ import java.util.concurrent.TimeUnit;
  *
  * @since 2.0
  */
-class EvictionTimer {
+final class EvictionTimer {
 
     /**
      * Thread factory that creates a daemon thread, with the context class 
loader from this class.
      */
-    private static class EvictorThreadFactory implements ThreadFactory {
+    private static final class EvictorThreadFactory implements ThreadFactory {
 
         @Override
         public Thread newThread(final Runnable runnable) {
@@ -70,7 +69,7 @@ class EvictionTimer {
      * Task that removes references to abandoned tasks and shuts
      * down the executor if there are no live tasks left.
      */
-    private static class Reaper implements Runnable {
+    private static final class Reaper implements Runnable {
         @Override
         public void run() {
             synchronized (EvictionTimer.class) {
@@ -95,7 +94,7 @@ class EvictionTimer {
      * no longer reachable, run is no-op.
      * @param <R> The kind of Runnable.
      */
-    private static class WeakRunner<R extends Runnable> implements Runnable {
+    private static final class WeakRunner<R extends Runnable> implements 
Runnable {
 
         private final WeakReference<R> ref;
 
@@ -120,7 +119,6 @@ class EvictionTimer {
         }
     }
 
-
     /** Executor instance */
     private static ScheduledThreadPoolExecutor executor; 
//@GuardedBy("EvictionTimer.class")
 
diff --git a/java/org/apache/tomcat/dbcp/pool2/impl/GenericKeyedObjectPool.java 
b/java/org/apache/tomcat/dbcp/pool2/impl/GenericKeyedObjectPool.java
index c03ca77923..07e89b6690 100644
--- a/java/org/apache/tomcat/dbcp/pool2/impl/GenericKeyedObjectPool.java
+++ b/java/org/apache/tomcat/dbcp/pool2/impl/GenericKeyedObjectPool.java
@@ -83,10 +83,8 @@ import org.apache.tomcat.dbcp.pool2.UsageTracking;
  * </p>
  *
  * @see GenericObjectPool
- *
  * @param <K> The type of keys maintained by this pool.
  * @param <T> Type of element pooled in this pool.
- *
  * @since 2.0
  */
 public class GenericKeyedObjectPool<K, T> extends BaseGenericObjectPool<T>
@@ -97,7 +95,7 @@ public class GenericKeyedObjectPool<K, T> extends 
BaseGenericObjectPool<T>
      *
      * @param <S> type of objects in the pool
      */
-    private static class ObjectDeque<S> {
+    private static final class ObjectDeque<S> {
 
         private final LinkedBlockingDeque<PooledObject<S>> idleObjects;
 
@@ -105,7 +103,7 @@ public class GenericKeyedObjectPool<K, T> extends 
BaseGenericObjectPool<T>
          * Number of instances created - number destroyed.
          * Invariant: createCount <= maxTotalPerKey
          */
-        private final AtomicInteger createCount = new AtomicInteger(0);
+        private final AtomicInteger createCount = new AtomicInteger();
 
         private long makeObjectCount;
         private final Object makeObjectCountLock = new Object();
@@ -200,7 +198,6 @@ public class GenericKeyedObjectPool<K, T> extends 
BaseGenericObjectPool<T>
     private volatile int minIdlePerKey =
             GenericKeyedObjectPoolConfig.DEFAULT_MIN_IDLE_PER_KEY;
 
-
     private volatile int maxTotalPerKey =
             GenericKeyedObjectPoolConfig.DEFAULT_MAX_TOTAL_PER_KEY;
 
@@ -209,7 +206,7 @@ public class GenericKeyedObjectPool<K, T> extends 
BaseGenericObjectPool<T>
     private final boolean fairness;
 
     /*
-     * My hash of sub-pools (ObjectQueue). The list of keys <b>must</b> be kept
+     * My hash of sub-pools (ObjectQueue). The list of keys 
<strong>must</strong> be kept
      * in step with {@link #poolKeyList} using {@link #keyLock} to ensure any
      * changes to the list of current keys is made in a thread-safe manner.
      */
@@ -218,7 +215,7 @@ public class GenericKeyedObjectPool<K, T> extends 
BaseGenericObjectPool<T>
 
     /*
      * List of pool keys - used to control eviction order. The list of keys
-     * <b>must</b> be kept in step with {@link #poolMap} using {@link #keyLock}
+     * <strong>must</strong> be kept in step with {@link #poolMap} using 
{@link #keyLock}
      * to ensure any changes to the list of current keys is made in a
      * thread-safe manner.
      */
@@ -232,11 +229,10 @@ public class GenericKeyedObjectPool<K, T> extends 
BaseGenericObjectPool<T>
      * {@link #maxTotal} but there will never be more than {@link #maxTotal}
      * created at any one time.
      */
-    private final AtomicInteger numTotal = new AtomicInteger(0);
+    private final AtomicInteger numTotal = new AtomicInteger();
 
     private Iterator<K> evictionKeyIterator; // @GuardedBy("evictionLock")
 
-
     private K evictionKey; // @GuardedBy("evictionLock")
 
     /**
@@ -299,7 +295,6 @@ public class GenericKeyedObjectPool<K, T> extends 
BaseGenericObjectPool<T>
      *
      * @param key The key to associate with the idle object
      * @param p The wrapped object to add.
-     *
      * @throws Exception If the associated factory fails to passivate the 
object
      */
     private void addIdleObject(final K key, final PooledObject<T> p) throws 
Exception {
@@ -329,7 +324,6 @@ public class GenericKeyedObjectPool<K, T> extends 
BaseGenericObjectPool<T>
      * </p>
      *
      * @param key the key a new instance should be added to
-     *
      * @throws Exception when {@link KeyedPooledObjectFactory#makeObject}
      *                   fails.
      */
@@ -410,7 +404,6 @@ public class GenericKeyedObjectPool<K, T> extends 
BaseGenericObjectPool<T>
      *                            to become available
      *
      * @return object instance from the keyed pool
-     *
      * @throws NoSuchElementException if a keyed object instance cannot be
      *                                returned because the pool is exhausted.
      *
@@ -520,7 +513,6 @@ public class GenericKeyedObjectPool<K, T> extends 
BaseGenericObjectPool<T>
      * on the maximum number of objects either per key or totally.
      *
      * @param objectDeque   The set of objects to check
-     *
      * @return The number of new objects to create
      */
     private int calculateDeficit(final ObjectDeque<T> objectDeque) {
@@ -644,11 +636,9 @@ public class GenericKeyedObjectPool<K, T> extends 
BaseGenericObjectPool<T>
         // build sorted map of idle objects
         final TreeMap<PooledObject<T>, K> map = new TreeMap<>();
 
-        poolMap.forEach((key, value) -> {
-            // Each item into the map using the PooledObject object as the
-            // key. It then gets sorted based on the idle time
-            value.getIdleObjects().forEach(p -> map.put(p, key));
-        });
+        // Each item into the map using the PooledObject object as the
+        // key. It then gets sorted based on the idle time
+        poolMap.forEach((key, value) -> value.getIdleObjects().forEach(p -> 
map.put(p, key)));
 
         // Now iterate created map and kill the first 15% plus one to account
         // for zero
@@ -657,9 +647,9 @@ public class GenericKeyedObjectPool<K, T> extends 
BaseGenericObjectPool<T>
 
         while (iter.hasNext() && itemsToRemove > 0) {
             final Entry<PooledObject<T>, K> entry = iter.next();
-            // kind of backwards on naming.  In the map, each key is the
+            // kind of backwards on naming. In the map, each key is the
             // PooledObject because it has the ordering with the timestamp
-            // value.  Each value that the key references is the key of the
+            // value. Each value that the key references is the key of the
             // list it belongs to.
             final K key = entry.getValue();
             final PooledObject<T> p = entry.getKey();
@@ -676,7 +666,6 @@ public class GenericKeyedObjectPool<K, T> extends 
BaseGenericObjectPool<T>
         }
     }
 
-
     /**
      * Closes the keyed object pool. Once the pool is closed,
      * {@link #borrowObject(Object)} will fail with IllegalStateException, but
@@ -716,14 +705,11 @@ public class GenericKeyedObjectPool<K, T> extends 
BaseGenericObjectPool<T>
         }
     }
 
-
     /**
      * Creates a new pooled object or null.
      *
      * @param key Key associated with new pooled object.
-     *
      * @return The new, wrapped pooled object. May return null.
-     *
      * @throws Exception If the objection creation fails.
      */
     private PooledObject<T> create(final K key) throws Exception {
@@ -876,7 +862,6 @@ public class GenericKeyedObjectPool<K, T> extends 
BaseGenericObjectPool<T>
      * @param always Should the object be destroyed even if it is not currently
      *               in the set of idle objects for the given key
      * @param destroyMode DestroyMode context provided to the factory
-     *
      * @return {@code true} if the object was destroyed, otherwise {@code 
false}
      * @throws Exception If the object destruction failed
      */
@@ -914,7 +899,6 @@ public class GenericKeyedObjectPool<K, T> extends 
BaseGenericObjectPool<T>
         }
     }
 
-
     @Override
     void ensureMinIdle() throws Exception {
         final int minIdlePerKeySave = getMinIdlePerKey();
@@ -940,7 +924,6 @@ public class GenericKeyedObjectPool<K, T> extends 
BaseGenericObjectPool<T>
      * </p>
      *
      * @param key The key to check for idle objects
-     *
      * @throws Exception If a new object is required and cannot be created
      */
     private void ensureMinIdle(final K key) throws Exception {
@@ -1115,7 +1098,6 @@ public class GenericKeyedObjectPool<K, T> extends 
BaseGenericObjectPool<T>
         }
     }
 
-
     /**
      * Gets a reference to the factory used to create, destroy and validate
      * the objects used by this pool.
@@ -1164,7 +1146,6 @@ public class GenericKeyedObjectPool<K, T> extends 
BaseGenericObjectPool<T>
      * is said to be exhausted. A negative value indicates no limit.
      *
      * @return the limit on the number of active instances per key
-     *
      * @see #setMaxTotalPerKey
      */
     @Override
@@ -1186,7 +1167,6 @@ public class GenericKeyedObjectPool<K, T> extends 
BaseGenericObjectPool<T>
      * </p>
      *
      * @return minimum size of the each keyed pool
-     *
      * @see #setTimeBetweenEvictionRunsMillis
      */
     @Override
@@ -1307,7 +1287,6 @@ public class GenericKeyedObjectPool<K, T> extends 
BaseGenericObjectPool<T>
      *
      * @param key pool key
      * @param obj instance to invalidate
-     *
      * @throws Exception             if an exception occurs destroying the
      *                               object
      * @throws IllegalStateException if obj does not belong to the pool
@@ -1328,7 +1307,6 @@ public class GenericKeyedObjectPool<K, T> extends 
BaseGenericObjectPool<T>
      * @param key pool key
      * @param obj instance to invalidate
      * @param destroyMode DestroyMode context provided to factory
-     *
      * @throws Exception             if an exception occurs destroying the
      *                               object
      * @throws IllegalStateException if obj does not belong to the pool
@@ -1372,8 +1350,7 @@ public class GenericKeyedObjectPool<K, T> extends 
BaseGenericObjectPool<T>
      * Registers a key for pool control and ensures that
      * {@link #getMinIdlePerKey()} idle instances are created.
      *
-     * @param key - The key to register for pool control.
-     *
+     * @param key   The key to register for pool control.
      * @throws Exception If the associated factory throws an exception
      */
     public void preparePool(final K key) throws Exception {
@@ -1391,7 +1368,6 @@ public class GenericKeyedObjectPool<K, T> extends 
BaseGenericObjectPool<T>
      * </p>
      *
      * @param k The key to register
-     *
      * @return The objects currently associated with the given key. If this
      *         method returns without throwing an exception then it will never
      *         return null.
@@ -1477,7 +1453,6 @@ public class GenericKeyedObjectPool<K, T> extends 
BaseGenericObjectPool<T>
      *
      * @param key pool key
      * @param obj instance to return to the keyed pool
-     *
      * @throws IllegalStateException if an object is returned to the pool that
      *                               was not borrowed from it or if an object 
is
      *                               returned to the pool multiple times
@@ -1623,7 +1598,6 @@ public class GenericKeyedObjectPool<K, T> extends 
BaseGenericObjectPool<T>
      * Sets the configuration.
      *
      * @param conf the new configuration to use. This is used by value.
-     *
      * @see GenericKeyedObjectPoolConfig
      */
     public void setConfig(final GenericKeyedObjectPoolConfig<T> conf) {
@@ -1660,7 +1634,6 @@ public class GenericKeyedObjectPool<K, T> extends 
BaseGenericObjectPool<T>
      * is said to be exhausted. A negative value indicates no limit.
      *
      * @param maxTotalPerKey the limit on the number of active instances per 
key
-     *
      * @see #getMaxTotalPerKey
      */
     public void setMaxTotalPerKey(final int maxTotalPerKey) {
@@ -1681,7 +1654,6 @@ public class GenericKeyedObjectPool<K, T> extends 
BaseGenericObjectPool<T>
      * </p>
      *
      * @param minIdlePerKey The minimum size of the each keyed pool
-     *
      * @see #getMinIdlePerKey()
      * @see #getMaxIdlePerKey()
      * @see #setDurationBetweenEvictionRuns(Duration)
diff --git 
a/java/org/apache/tomcat/dbcp/pool2/impl/GenericKeyedObjectPoolConfig.java 
b/java/org/apache/tomcat/dbcp/pool2/impl/GenericKeyedObjectPoolConfig.java
index 9b4ddd0a60..14fe7b139c 100644
--- a/java/org/apache/tomcat/dbcp/pool2/impl/GenericKeyedObjectPoolConfig.java
+++ b/java/org/apache/tomcat/dbcp/pool2/impl/GenericKeyedObjectPoolConfig.java
@@ -31,30 +31,33 @@ package org.apache.tomcat.dbcp.pool2.impl;
 public class GenericKeyedObjectPoolConfig<T> extends BaseObjectPoolConfig<T> {
 
     /**
-     * The default value for the {@code maxTotalPerKey} configuration 
attribute.
+     * The default value for the {@code maxTotalPerKey} configuration 
attribute: {@value}.
+     *
      * @see GenericKeyedObjectPool#getMaxTotalPerKey()
      */
     public static final int DEFAULT_MAX_TOTAL_PER_KEY = 8;
 
     /**
-     * The default value for the {@code maxTotal} configuration attribute.
+     * The default value for the {@code maxTotal} configuration attribute: 
{@value}.
+     *
      * @see GenericKeyedObjectPool#getMaxTotal()
      */
     public static final int DEFAULT_MAX_TOTAL = -1;
 
     /**
-     * The default value for the {@code minIdlePerKey} configuration attribute.
+     * The default value for the {@code minIdlePerKey} configuration 
attribute: {@value}.
+     *
      * @see GenericKeyedObjectPool#getMinIdlePerKey()
      */
     public static final int DEFAULT_MIN_IDLE_PER_KEY = 0;
 
     /**
-     * The default value for the {@code maxIdlePerKey} configuration attribute.
+     * The default value for the {@code maxIdlePerKey} configuration 
attribute: {@value}.
+     *
      * @see GenericKeyedObjectPool#getMaxIdlePerKey()
      */
     public static final int DEFAULT_MAX_IDLE_PER_KEY = 8;
 
-
     private int minIdlePerKey = DEFAULT_MIN_IDLE_PER_KEY;
 
     private int maxIdlePerKey = DEFAULT_MAX_IDLE_PER_KEY;
@@ -80,7 +83,7 @@ public class GenericKeyedObjectPoolConfig<T> extends 
BaseObjectPoolConfig<T> {
     }
 
     /**
-     * Get the value for the {@code maxIdlePerKey} configuration attribute
+     * Gets the value for the {@code maxIdlePerKey} configuration attribute
      * for pools created with this configuration instance.
      *
      * @return  The current setting of {@code maxIdlePerKey} for this
@@ -93,7 +96,7 @@ public class GenericKeyedObjectPoolConfig<T> extends 
BaseObjectPoolConfig<T> {
     }
 
     /**
-     * Get the value for the {@code maxTotal} configuration attribute
+     * Gets the value for the {@code maxTotal} configuration attribute
      * for pools created with this configuration instance.
      *
      * @return  The current setting of {@code maxTotal} for this
@@ -106,7 +109,7 @@ public class GenericKeyedObjectPoolConfig<T> extends 
BaseObjectPoolConfig<T> {
     }
 
     /**
-     * Get the value for the {@code maxTotalPerKey} configuration attribute
+     * Gets the value for the {@code maxTotalPerKey} configuration attribute
      * for pools created with this configuration instance.
      *
      * @return  The current setting of {@code maxTotalPerKey} for this
@@ -119,7 +122,7 @@ public class GenericKeyedObjectPoolConfig<T> extends 
BaseObjectPoolConfig<T> {
     }
 
     /**
-     * Get the value for the {@code minIdlePerKey} configuration attribute
+     * Gets the value for the {@code minIdlePerKey} configuration attribute
      * for pools created with this configuration instance.
      *
      * @return  The current setting of {@code minIdlePerKey} for this
@@ -132,7 +135,7 @@ public class GenericKeyedObjectPoolConfig<T> extends 
BaseObjectPoolConfig<T> {
     }
 
     /**
-     * Set the value for the {@code maxIdlePerKey} configuration attribute for
+     * Sets the value for the {@code maxIdlePerKey} configuration attribute for
      * pools created with this configuration instance.
      *
      * @param maxIdlePerKey The new setting of {@code maxIdlePerKey}
@@ -145,7 +148,7 @@ public class GenericKeyedObjectPoolConfig<T> extends 
BaseObjectPoolConfig<T> {
     }
 
     /**
-     * Set the value for the {@code maxTotal} configuration attribute for
+     * Sets the value for the {@code maxTotal} configuration attribute for
      * pools created with this configuration instance.
      *
      * @param maxTotal The new setting of {@code maxTotal}
@@ -158,7 +161,7 @@ public class GenericKeyedObjectPoolConfig<T> extends 
BaseObjectPoolConfig<T> {
     }
 
     /**
-     * Set the value for the {@code maxTotalPerKey} configuration attribute for
+     * Sets the value for the {@code maxTotalPerKey} configuration attribute 
for
      * pools created with this configuration instance.
      *
      * @param maxTotalPerKey The new setting of {@code maxTotalPerKey}
@@ -171,7 +174,7 @@ public class GenericKeyedObjectPoolConfig<T> extends 
BaseObjectPoolConfig<T> {
     }
 
     /**
-     * Set the value for the {@code minIdlePerKey} configuration attribute for
+     * Sets the value for the {@code minIdlePerKey} configuration attribute for
      * pools created with this configuration instance.
      *
      * @param minIdlePerKey The new setting of {@code minIdlePerKey}
diff --git a/java/org/apache/tomcat/dbcp/pool2/impl/GenericObjectPool.java 
b/java/org/apache/tomcat/dbcp/pool2/impl/GenericObjectPool.java
index 6afb61cde8..98f9819cc0 100644
--- a/java/org/apache/tomcat/dbcp/pool2/impl/GenericObjectPool.java
+++ b/java/org/apache/tomcat/dbcp/pool2/impl/GenericObjectPool.java
@@ -74,9 +74,7 @@ import org.apache.tomcat.dbcp.pool2.UsageTracking;
  * </p>
  *
  * @see GenericKeyedObjectPool
- *
  * @param <T> Type of element pooled in this pool.
- *
  * @since 2.0
  */
 public class GenericObjectPool<T> extends BaseGenericObjectPool<T>
@@ -87,7 +85,9 @@ public class GenericObjectPool<T> extends 
BaseGenericObjectPool<T>
         "org.apache.commons.pool2:type=GenericObjectPool,name=";
 
     private static void wait(final Object obj, final Duration duration) throws 
InterruptedException {
-        obj.wait(duration.toMillis(), duration.getNano() % 1_000_000);
+        if (!duration.isNegative()) {
+            obj.wait(duration.toMillis(), duration.getNano() % 1_000_000);
+        }
     }
 
     private volatile String factoryType;
@@ -185,7 +185,6 @@ public class GenericObjectPool<T> extends 
BaseGenericObjectPool<T>
      * is null, this is a no-op (no exception, but no impact on the pool).
      *
      * @param p The object to make idle
-     *
      * @throws Exception If the factory fails to passivate the object
      */
     private void addIdleObject(final PooledObject<T> p) throws Exception {
@@ -211,7 +210,6 @@ public class GenericObjectPool<T> extends 
BaseGenericObjectPool<T>
      * is thrown. If there is no factory set (factory == null), an {@code 
IllegalStateException}
      * is thrown.
      * </p>
-     *
      */
     @Override
     public void addObject() throws Exception {
@@ -219,7 +217,7 @@ public class GenericObjectPool<T> extends 
BaseGenericObjectPool<T>
         if (factory == null) {
             throw new IllegalStateException("Cannot add objects without a 
factory.");
         }
-        addIdleObject(create());
+        addIdleObject(create(getMaxWaitDuration()));
     }
 
     /**
@@ -273,9 +271,7 @@ public class GenericObjectPool<T> extends 
BaseGenericObjectPool<T>
      * available instances in request arrival order.
      * </p>
      *
-     * @param borrowMaxWaitDuration The time to wait for an object
-     *                            to become available
-     *
+     * @param borrowMaxWaitDuration The time to wait for an object to become 
available, not null.
      * @return object instance from the pool
      * @throws NoSuchElementException if an instance cannot be returned
      * @throws Exception if an object instance cannot be returned due to an 
error
@@ -283,38 +279,35 @@ public class GenericObjectPool<T> extends 
BaseGenericObjectPool<T>
      */
     public T borrowObject(final Duration borrowMaxWaitDuration) throws 
Exception {
         assertOpen();
-
+        final Instant startInstant = Instant.now();
+        final boolean negativeDuration = borrowMaxWaitDuration.isNegative();
+        Duration remainingWaitDuration = borrowMaxWaitDuration;
         final AbandonedConfig ac = this.abandonedConfig;
-        if (ac != null && ac.getRemoveAbandonedOnBorrow() && getNumIdle() < 2 
&&
-                getNumActive() > getMaxTotal() - 3) {
+        if (ac != null && ac.getRemoveAbandonedOnBorrow() && getNumIdle() < 2 
&& getNumActive() > getMaxTotal() - 3) {
             removeAbandoned(ac);
         }
-
         PooledObject<T> p = null;
-
         // Get local copy of current config so it is consistent for entire
         // method execution
         final boolean blockWhenExhausted = getBlockWhenExhausted();
-
         boolean create;
-        final Instant waitTime = Instant.now();
-
         while (p == null) {
+            remainingWaitDuration = 
remainingWaitDuration.minus(durationSince(startInstant));
             create = false;
             p = idleObjects.pollFirst();
             if (p == null) {
-                p = create();
+                p = create(remainingWaitDuration);
                 if (!PooledObject.isNull(p)) {
                     create = true;
                 }
             }
             if (blockWhenExhausted) {
                 if (PooledObject.isNull(p)) {
-                    p = borrowMaxWaitDuration.isNegative() ? 
idleObjects.takeFirst() : idleObjects.pollFirst(borrowMaxWaitDuration);
+                    p = negativeDuration ? idleObjects.takeFirst() : 
idleObjects.pollFirst(remainingWaitDuration);
                 }
                 if (PooledObject.isNull(p)) {
                     throw new NoSuchElementException(appendStats(
-                            "Timeout waiting for idle object, 
borrowMaxWaitDuration=" + borrowMaxWaitDuration));
+                            "Timeout waiting for idle object, 
borrowMaxWaitDuration=" + remainingWaitDuration));
                 }
             } else if (PooledObject.isNull(p)) {
                 throw new NoSuchElementException(appendStats("Pool 
exhausted"));
@@ -322,7 +315,6 @@ public class GenericObjectPool<T> extends 
BaseGenericObjectPool<T>
             if (!p.allocate()) {
                 p = null;
             }
-
             if (!PooledObject.isNull(p)) {
                 try {
                     factory.activateObject(p);
@@ -367,12 +359,14 @@ public class GenericObjectPool<T> extends 
BaseGenericObjectPool<T>
                 }
             }
         }
-
-        updateStatsBorrow(p, Duration.between(waitTime, Instant.now()));
-
+        updateStatsBorrow(p, durationSince(startInstant));
         return p.getObject();
     }
 
+    private Duration durationSince(final Instant startInstant) {
+        return Duration.between(startInstant, Instant.now());
+    }
+
     /**
      * Borrows an object from the pool using the specific waiting time which 
only
      * applies if {@link #getBlockWhenExhausted()} is true.
@@ -415,11 +409,8 @@ public class GenericObjectPool<T> extends 
BaseGenericObjectPool<T>
      *
      * @param borrowMaxWaitMillis The time to wait in milliseconds for an 
object
      *                            to become available
-     *
      * @return object instance from the pool
-     *
      * @throws NoSuchElementException if an instance cannot be returned
-     *
      * @throws Exception if an object instance cannot be returned due to an
      *                   error
      */
@@ -504,20 +495,19 @@ public class GenericObjectPool<T> extends 
BaseGenericObjectPool<T>
      * If the factory makeObject returns null, this method throws a 
NullPointerException.
      * </p>
      *
+     * @param maxWaitDuration The time to wait for an object to become 
available.
      * @return The new wrapped pooled object or null.
      * @throws Exception if the object factory's {@code makeObject} fails
      */
-    private PooledObject<T> create() throws Exception {
+    private PooledObject<T> create(final Duration maxWaitDuration) throws 
Exception {
+        final Instant startInstant = Instant.now();
+        Duration remainingWaitDuration = maxWaitDuration.isNegative() ? 
Duration.ZERO : maxWaitDuration;
         int localMaxTotal = getMaxTotal();
         // This simplifies the code later in this method
         if (localMaxTotal < 0) {
             localMaxTotal = Integer.MAX_VALUE;
         }
-
         final Instant localStartInstant = Instant.now();
-        final Duration maxWaitDurationRaw = getMaxWaitDuration();
-        final Duration localMaxWaitDuration = maxWaitDurationRaw.isNegative() 
? Duration.ZERO : maxWaitDurationRaw;
-
         // Flag that indicates if create should:
         // - TRUE:  call the factory to create an object
         // - FALSE: return null
@@ -525,6 +515,8 @@ public class GenericObjectPool<T> extends 
BaseGenericObjectPool<T>
         //          call the factory
         Boolean create = null;
         while (create == null) {
+            // remainingWaitDuration handles spurious wakeup from wait().
+            remainingWaitDuration = 
remainingWaitDuration.minus(durationSince(startInstant));
             synchronized (makeObjectCountLock) {
                 final long newCreateCount = createCount.incrementAndGet();
                 if (newCreateCount > localMaxTotal) {
@@ -541,7 +533,7 @@ public class GenericObjectPool<T> extends 
BaseGenericObjectPool<T>
                         // 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.
-                        wait(makeObjectCountLock, localMaxWaitDuration);
+                        wait(makeObjectCountLock, remainingWaitDuration);
                     }
                 } else {
                     // The pool is not at capacity. Create a new object.
@@ -549,10 +541,9 @@ public class GenericObjectPool<T> extends 
BaseGenericObjectPool<T>
                     create = Boolean.TRUE;
                 }
             }
-
-            // Do not block more if maxWaitTimeMillis is set.
-            if (create == null && 
localMaxWaitDuration.compareTo(Duration.ZERO) > 0 &&
-                    Duration.between(localStartInstant, 
Instant.now()).compareTo(localMaxWaitDuration) >= 0) {
+            // Do not block more if remainingWaitDuration > 0.
+            if (create == null && 
remainingWaitDuration.compareTo(Duration.ZERO) > 0 &&
+                    
durationSince(localStartInstant).compareTo(remainingWaitDuration) >= 0) {
                 create = Boolean.FALSE;
             }
         }
@@ -598,7 +589,6 @@ public class GenericObjectPool<T> extends 
BaseGenericObjectPool<T>
      *
      * @param toDestroy The wrapped pooled object to destroy
      * @param destroyMode DestroyMode context provided to the factory
-     *
      * @throws Exception If the factory fails to destroy the pooled object
      *                   cleanly
      */
@@ -637,7 +627,7 @@ public class GenericObjectPool<T> extends 
BaseGenericObjectPool<T>
         }
 
         while (idleObjects.size() < idleCount) {
-            final PooledObject<T> p = create();
+            final PooledObject<T> p = create(getMaxWaitDuration());
             if (PooledObject.isNull(p)) {
                 // Can't create objects, no reason to think another call to
                 // create will work. Give up.
@@ -825,7 +815,6 @@ public class GenericObjectPool<T> extends 
BaseGenericObjectPool<T>
      *
      * @return the maximum number of "idle" instances that can be held in the
      *         pool or a negative value if there is no limit
-     *
      * @see #setMaxIdle
      */
     @Override
@@ -845,7 +834,6 @@ public class GenericObjectPool<T> extends 
BaseGenericObjectPool<T>
      * </p>
      *
      * @return The minimum number of objects.
-     *
      * @see #setMinIdle(int)
      * @see #setMaxIdle(int)
      * @see #setDurationBetweenEvictionRuns(Duration)
@@ -1108,7 +1096,6 @@ public class GenericObjectPool<T> extends 
BaseGenericObjectPool<T>
      * Sets the base pool configuration.
      *
      * @param conf the new configuration to use. This is used by value.
-     *
      * @see GenericObjectPoolConfig
      */
     public void setConfig(final GenericObjectPoolConfig<T> conf) {
@@ -1131,7 +1118,6 @@ public class GenericObjectPool<T> extends 
BaseGenericObjectPool<T>
      *            The cap on the number of "idle" instances in the pool. Use a
      *            negative value to indicate an unlimited number of idle
      *            instances
-     *
      * @see #getMaxIdle
      */
     public void setMaxIdle(final int maxIdle) {
@@ -1151,7 +1137,6 @@ public class GenericObjectPool<T> extends 
BaseGenericObjectPool<T>
      *
      * @param minIdle
      *            The minimum number of objects.
-     *
      * @see #getMinIdle()
      * @see #getMaxIdle()
      * @see #getDurationBetweenEvictionRuns()
diff --git 
a/java/org/apache/tomcat/dbcp/pool2/impl/GenericObjectPoolConfig.java 
b/java/org/apache/tomcat/dbcp/pool2/impl/GenericObjectPoolConfig.java
index f01c3e7323..ec3271e879 100644
--- a/java/org/apache/tomcat/dbcp/pool2/impl/GenericObjectPoolConfig.java
+++ b/java/org/apache/tomcat/dbcp/pool2/impl/GenericObjectPoolConfig.java
@@ -31,24 +31,26 @@ package org.apache.tomcat.dbcp.pool2.impl;
 public class GenericObjectPoolConfig<T> extends BaseObjectPoolConfig<T> {
 
     /**
-     * The default value for the {@code maxTotal} configuration attribute.
+     * The default value for the {@code maxTotal} configuration attribute: 
{@value}.
+     *
      * @see GenericObjectPool#getMaxTotal()
      */
     public static final int DEFAULT_MAX_TOTAL = 8;
 
     /**
-     * The default value for the {@code maxIdle} configuration attribute.
+     * The default value for the {@code maxIdle} configuration attribute: 
{@value}.
+     *
      * @see GenericObjectPool#getMaxIdle()
      */
     public static final int DEFAULT_MAX_IDLE = 8;
 
     /**
-     * The default value for the {@code minIdle} configuration attribute.
+     * The default value for the {@code minIdle} configuration attribute: 
{@value}.
+     *
      * @see GenericObjectPool#getMinIdle()
      */
     public static final int DEFAULT_MIN_IDLE = 0;
 
-
     private int maxTotal = DEFAULT_MAX_TOTAL;
 
     private int maxIdle = DEFAULT_MAX_IDLE;
@@ -66,7 +68,7 @@ public class GenericObjectPoolConfig<T> extends 
BaseObjectPoolConfig<T> {
     }
 
     /**
-     * Get the value for the {@code maxIdle} configuration attribute
+     * Gets the value for the {@code maxIdle} configuration attribute
      * for pools created with this configuration instance.
      *
      * @return  The current setting of {@code maxIdle} for this
@@ -78,9 +80,8 @@ public class GenericObjectPoolConfig<T> extends 
BaseObjectPoolConfig<T> {
         return maxIdle;
     }
 
-
     /**
-     * Get the value for the {@code maxTotal} configuration attribute
+     * Gets the value for the {@code maxTotal} configuration attribute
      * for pools created with this configuration instance.
      *
      * @return  The current setting of {@code maxTotal} for this
@@ -93,7 +94,7 @@ public class GenericObjectPoolConfig<T> extends 
BaseObjectPoolConfig<T> {
     }
 
     /**
-     * Get the value for the {@code minIdle} configuration attribute
+     * Gets the value for the {@code minIdle} configuration attribute
      * for pools created with this configuration instance.
      *
      * @return  The current setting of {@code minIdle} for this
@@ -105,9 +106,8 @@ public class GenericObjectPoolConfig<T> extends 
BaseObjectPoolConfig<T> {
         return minIdle;
     }
 
-
     /**
-     * Set the value for the {@code maxIdle} configuration attribute for
+     * Sets the value for the {@code maxIdle} configuration attribute for
      * pools created with this configuration instance.
      *
      * @param maxIdle The new setting of {@code maxIdle}
@@ -120,7 +120,7 @@ public class GenericObjectPoolConfig<T> extends 
BaseObjectPoolConfig<T> {
     }
 
     /**
-     * Set the value for the {@code maxTotal} configuration attribute for
+     * Sets the value for the {@code maxTotal} configuration attribute for
      * pools created with this configuration instance.
      *
      * @param maxTotal The new setting of {@code maxTotal}
@@ -133,7 +133,7 @@ public class GenericObjectPoolConfig<T> extends 
BaseObjectPoolConfig<T> {
     }
 
     /**
-     * Set the value for the {@code minIdle} configuration attribute for
+     * Sets the value for the {@code minIdle} configuration attribute for
      * pools created with this configuration instance.
      *
      * @param minIdle The new setting of {@code minIdle}
diff --git 
a/java/org/apache/tomcat/dbcp/pool2/impl/InterruptibleReentrantLock.java 
b/java/org/apache/tomcat/dbcp/pool2/impl/InterruptibleReentrantLock.java
index ec06e0101f..63be6e1678 100644
--- a/java/org/apache/tomcat/dbcp/pool2/impl/InterruptibleReentrantLock.java
+++ b/java/org/apache/tomcat/dbcp/pool2/impl/InterruptibleReentrantLock.java
@@ -29,7 +29,7 @@ import java.util.concurrent.locks.ReentrantLock;
  *
  * @since 2.0
  */
-class InterruptibleReentrantLock extends ReentrantLock {
+final class InterruptibleReentrantLock extends ReentrantLock {
 
     private static final long serialVersionUID = 1L;
 
diff --git a/java/org/apache/tomcat/dbcp/pool2/impl/LinkedBlockingDeque.java 
b/java/org/apache/tomcat/dbcp/pool2/impl/LinkedBlockingDeque.java
index 3b95ee9f13..7edd10f64e 100644
--- a/java/org/apache/tomcat/dbcp/pool2/impl/LinkedBlockingDeque.java
+++ b/java/org/apache/tomcat/dbcp/pool2/impl/LinkedBlockingDeque.java
@@ -65,7 +65,7 @@ import java.util.concurrent.locks.Condition;
  *
  * @since 2.0
  */
-class LinkedBlockingDeque<E> extends AbstractQueue<E>
+final class LinkedBlockingDeque<E> extends AbstractQueue<E>
         implements Deque<E>, Serializable {
 
     /*
@@ -173,7 +173,6 @@ class LinkedBlockingDeque<E> extends AbstractQueue<E>
          * iterator.
          *
          * @param n given node
-         *
          * @return next node
          */
         abstract Node<E> nextNode(Node<E> n);
@@ -222,7 +221,7 @@ class LinkedBlockingDeque<E> extends AbstractQueue<E>
     }
 
     /** Descending iterator */
-    private class DescendingItr extends AbstractItr {
+    private final class DescendingItr extends AbstractItr {
         @Override
         Node<E> firstNode() { return last; }
         @Override
@@ -230,7 +229,7 @@ class LinkedBlockingDeque<E> extends AbstractQueue<E>
     }
 
     /** Forward iterator */
-    private class Itr extends AbstractItr {
+    private final class Itr extends AbstractItr {
         @Override
         Node<E> firstNode() { return first; }
         @Override
@@ -327,7 +326,6 @@ class LinkedBlockingDeque<E> extends AbstractQueue<E>
         this(Integer.MAX_VALUE, fairness);
     }
 
-
     // Basic linking and unlinking operations, called only while holding lock
 
     /**
@@ -464,9 +462,7 @@ class LinkedBlockingDeque<E> extends AbstractQueue<E>
      * Drains the queue to the specified collection.
      *
      * @param c The collection to add the elements to
-     *
      * @return number of elements added to the collection
-     *
      * @throws UnsupportedOperationException if the add operation is not
      *         supported by the specified collection
      * @throws ClassCastException if the class of the elements held by this
@@ -483,9 +479,8 @@ class LinkedBlockingDeque<E> extends AbstractQueue<E>
      * Drains no more than the specified number of elements from the queue to 
the
      * specified collection.
      *
-     * @param c           collection to add the elements to
+     * @param collection collection to add the elements to
      * @param maxElements maximum number of elements to remove from the queue
-     *
      * @return number of elements added to the collection
      * @throws UnsupportedOperationException if the add operation is not
      *         supported by the specified collection
@@ -495,16 +490,16 @@ class LinkedBlockingDeque<E> extends AbstractQueue<E>
      * @throws NullPointerException if c is null
      * @throws IllegalArgumentException if c is this instance
      */
-    public int drainTo(final Collection<? super E> c, final int maxElements) {
-        Objects.requireNonNull(c, "c");
-        if (c == this) {
+    public int drainTo(final Collection<? super E> collection, final int 
maxElements) {
+        Objects.requireNonNull(collection, "collection");
+        if (collection == this) {
             throw new IllegalArgumentException();
         }
         lock.lock();
         try {
             final int n = Math.min(maxElements, count);
             for (int i = 0; i < n; i++) {
-                c.add(first.item);   // In this order, in case add() throws.
+                collection.add(first.item); // In this order, in case add() 
throws.
                 unlinkFirst();
             }
             return n;
@@ -610,7 +605,6 @@ class LinkedBlockingDeque<E> extends AbstractQueue<E>
      * Links provided element as first element, or returns false if full.
      *
      * @param e The element to link as the first element.
-     *
      * @return {@code true} if successful, otherwise {@code false}
      */
     private boolean linkFirst(final E e) {
@@ -635,7 +629,6 @@ class LinkedBlockingDeque<E> extends AbstractQueue<E>
      * Links provided element as last element, or returns false if full.
      *
      * @param e The element to link as the last element.
-     *
      * @return {@code true} if successful, otherwise {@code false}
      */
     private boolean linkLast(final E e) {
@@ -669,9 +662,7 @@ class LinkedBlockingDeque<E> extends AbstractQueue<E>
      *
      * @param e         element to link
      * @param timeout   length of time to wait
-     *
      * @return {@code true} if successful, otherwise {@code false}
-     *
      * @throws NullPointerException if e is null
      * @throws InterruptedException if the thread is interrupted whilst waiting
      *         for space
@@ -689,9 +680,7 @@ class LinkedBlockingDeque<E> extends AbstractQueue<E>
      * @param e         element to link
      * @param timeout   length of time to wait
      * @param unit      units that timeout is expressed in
-     *
      * @return {@code true} if successful, otherwise {@code false}
-     *
      * @throws NullPointerException if e is null
      * @throws InterruptedException if the thread is interrupted whilst waiting
      *         for space
@@ -717,9 +706,7 @@ class LinkedBlockingDeque<E> extends AbstractQueue<E>
      *
      * @param e         element to link
      * @param timeout   length of time to wait
-     *
      * @return {@code true} if successful, otherwise {@code false}
-     *
      * @throws NullPointerException if e is null
      * @throws InterruptedException if the thread is interrupted whilst waiting
      *         for space
@@ -748,9 +735,7 @@ class LinkedBlockingDeque<E> extends AbstractQueue<E>
      * @param e         element to link
      * @param timeout   length of time to wait
      * @param unit      units that timeout is expressed in
-     *
      * @return {@code true} if successful, otherwise {@code false}
-     *
      * @throws NullPointerException if e is null
      * @throws InterruptedException if the thread is interrupted whilst waiting
      *         for space
@@ -776,9 +761,7 @@ class LinkedBlockingDeque<E> extends AbstractQueue<E>
      *
      * @param e         element to link
      * @param timeout   length of time to wait
-     *
      * @return {@code true} if successful, otherwise {@code false}
-     *
      * @throws NullPointerException if e is null
      * @throws InterruptedException if the thread is interrupted whist waiting
      *         for space
@@ -807,9 +790,7 @@ class LinkedBlockingDeque<E> extends AbstractQueue<E>
      * @param e         element to link
      * @param timeout   length of time to wait
      * @param unit      units that timeout is expressed in
-     *
      * @return {@code true} if successful, otherwise {@code false}
-     *
      * @throws NullPointerException if e is null
      * @throws InterruptedException if the thread is interrupted whist waiting
      *         for space
@@ -857,7 +838,6 @@ class LinkedBlockingDeque<E> extends AbstractQueue<E>
      * <p>This method is equivalent to {@link #pollFirst(long, TimeUnit)}.
      *
      * @param timeout   length of time to wait
-     *
      * @return the unlinked element
      * @throws InterruptedException if the current thread is interrupted
      */
@@ -873,7 +853,6 @@ class LinkedBlockingDeque<E> extends AbstractQueue<E>
      *
      * @param timeout   length of time to wait
      * @param unit      units that timeout is expressed in
-     *
      * @return the unlinked element
      * @throws InterruptedException if the current thread is interrupted
      */
@@ -896,7 +875,6 @@ class LinkedBlockingDeque<E> extends AbstractQueue<E>
      * to do so if the queue is empty.
      *
      * @param timeout   length of time to wait
-     *
      * @return the unlinked element
      * @throws InterruptedException if the current thread is interrupted
      */
@@ -923,7 +901,6 @@ class LinkedBlockingDeque<E> extends AbstractQueue<E>
      *
      * @param timeout   length of time to wait
      * @param unit      units that timeout is expressed in
-     *
      * @return the unlinked element
      * @throws InterruptedException if the current thread is interrupted
      */
@@ -946,7 +923,6 @@ class LinkedBlockingDeque<E> extends AbstractQueue<E>
      * to do so if the queue is empty.
      *
      * @param timeout   length of time to wait
-     *
      * @return the unlinked element
      * @throws InterruptedException if the current thread is interrupted
      */
@@ -974,7 +950,6 @@ class LinkedBlockingDeque<E> extends AbstractQueue<E>
      *
      * @param timeout   length of time to wait
      * @param unit      units that timeout is expressed in
-     *
      * @return the unlinked element
      * @throws InterruptedException if the current thread is interrupted
      */
@@ -1002,7 +977,6 @@ class LinkedBlockingDeque<E> extends AbstractQueue<E>
      * </p>
      *
      * @param e element to link
-     *
      * @throws NullPointerException if e is null
      * @throws InterruptedException if the thread is interrupted whilst waiting
      *         for space
@@ -1016,7 +990,6 @@ class LinkedBlockingDeque<E> extends AbstractQueue<E>
      * is space to do so if the queue is full.
      *
      * @param e element to link
-     *
      * @throws NullPointerException if e is null
      * @throws InterruptedException if the thread is interrupted whilst waiting
      *         for space
@@ -1038,7 +1011,6 @@ class LinkedBlockingDeque<E> extends AbstractQueue<E>
      * is space to do so if the queue is full.
      *
      * @param e element to link
-     *
      * @throws NullPointerException if e is null
      * @throws InterruptedException if the thread is interrupted whilst waiting
      *         for space
diff --git a/java/org/apache/tomcat/dbcp/pool2/impl/PoolImplUtils.java 
b/java/org/apache/tomcat/dbcp/pool2/impl/PoolImplUtils.java
index eaea8ca88e..f552f38bc9 100644
--- a/java/org/apache/tomcat/dbcp/pool2/impl/PoolImplUtils.java
+++ b/java/org/apache/tomcat/dbcp/pool2/impl/PoolImplUtils.java
@@ -32,13 +32,12 @@ import org.apache.tomcat.dbcp.pool2.PooledObjectFactory;
  *
  * @since 2.0
  */
-class PoolImplUtils {
+final class PoolImplUtils {
 
     /**
      * Identifies the concrete type of object that an object factory creates.
      *
      * @param factoryClass The factory to examine
-     *
      * @return the type of object the factory creates
      */
     @SuppressWarnings("rawtypes")
@@ -73,7 +72,6 @@ class PoolImplUtils {
      * @param type The interface that defines a generic type
      * @param clazz The class that implements the interface with a concrete 
type
      * @param <T> The interface type
-     *
      * @return concrete type used by the implementation
      */
     private static <T> Object getGenericType(final Class<T> type, final 
Class<? extends T> clazz) {
@@ -135,7 +133,6 @@ class PoolImplUtils {
      *
      * @param clazz defining class
      * @param argType the type argument of interest
-     *
      * @return An instance of {@link Class} representing the type used by the 
type parameter or an instance of
      *         {@link Integer} representing the index for the type in the 
definition of the defining class
      */
@@ -227,7 +224,7 @@ class PoolImplUtils {
      * @return a Duration.
      */
     static Duration toDuration(final long amount, final TimeUnit timeUnit) {
-        return Duration.of(amount, PoolImplUtils.toChronoUnit(timeUnit));
+        return Duration.of(amount, toChronoUnit(timeUnit));
     }
 
 }
diff --git 
a/java/org/apache/tomcat/dbcp/pool2/impl/SoftReferenceObjectPool.java 
b/java/org/apache/tomcat/dbcp/pool2/impl/SoftReferenceObjectPool.java
index 8a232ea44f..b64597fda2 100644
--- a/java/org/apache/tomcat/dbcp/pool2/impl/SoftReferenceObjectPool.java
+++ b/java/org/apache/tomcat/dbcp/pool2/impl/SoftReferenceObjectPool.java
@@ -58,7 +58,6 @@ public class SoftReferenceObjectPool<T> extends 
BaseObjectPool<T> {
     /** Total number of instances that have been destroyed */
     private long destroyCount; // @GuardedBy("this")
 
-
     /** Total number of instances that have been created */
     private long createCount; // @GuardedBy("this")
 
@@ -267,7 +266,6 @@ public class SoftReferenceObjectPool<T> extends 
BaseObjectPool<T> {
      * references pools.
      *
      * @param toDestroy PooledSoftReference to destroy
-     *
      * @throws Exception If an error occurs while trying to destroy the object
      */
     private void destroy(final PooledSoftReference<T> toDestroy) throws 
Exception {
@@ -348,7 +346,8 @@ public class SoftReferenceObjectPool<T> extends 
BaseObjectPool<T> {
         // Remove wrappers for enqueued references from idle and allReferences 
lists
         removeClearedReferences(idleReferences.iterator());
         removeClearedReferences(allReferences.iterator());
-        while (refQueue.poll() != null) { // NOPMD
+        while (refQueue.poll() != null) {
+            // loop until null
         }
     }
 
diff --git a/java/org/apache/tomcat/dbcp/pool2/impl/ThrowableCallStack.java 
b/java/org/apache/tomcat/dbcp/pool2/impl/ThrowableCallStack.java
index 6f187559e5..dc63408442 100644
--- a/java/org/apache/tomcat/dbcp/pool2/impl/ThrowableCallStack.java
+++ b/java/org/apache/tomcat/dbcp/pool2/impl/ThrowableCallStack.java
@@ -19,6 +19,7 @@ package org.apache.tomcat.dbcp.pool2.impl;
 import java.io.PrintWriter;
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
+import java.time.Instant;
 
 /**
  * CallStack strategy that uses the stack trace from a {@link Throwable}. This 
strategy, while slower than the
@@ -33,13 +34,32 @@ public class ThrowableCallStack implements CallStack {
     /**
      * A snapshot of a throwable.
      */
-    private static class Snapshot extends Throwable {
+    private static final class Snapshot extends Throwable {
+
         private static final long serialVersionUID = 1L;
-        private final long timestampMillis = System.currentTimeMillis();
+        private final Instant timestamp;
+
+        /**
+         * Constructs a new instance with its message set to the now instant.
+         */
+        Snapshot() {
+            this(Instant.now());
+        }
+
+        /**
+         * Constructs a new instance and use the timestamp as the message with 
using {@link DateTimeFormatter#ISO_INSTANT} for more precision.
+         *
+         * @param timestamp normally the now instant.
+         */
+        private Snapshot(final Instant timestamp) {
+            super(timestamp.toString());
+            this.timestamp = timestamp;
+        }
     }
 
     private final String messageFormat;
 
+    // We keep the SimpleDateFormat for backward compatibility instead of a 
DateTimeFormatter.
     //@GuardedBy("dateFormat")
     private final DateFormat dateFormat;
 
@@ -77,7 +97,8 @@ public class ThrowableCallStack implements CallStack {
             message = messageFormat;
         } else {
             synchronized (dateFormat) {
-                message = 
dateFormat.format(Long.valueOf(snapshotRef.timestampMillis));
+                // The throwable message is in {@link 
DateTimeFormatter#ISO_INSTANT} format for more precision.
+                message = 
dateFormat.format(Long.valueOf(snapshotRef.timestamp.toEpochMilli()));
             }
         }
         writer.println(message);
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 8ac8af009e..7997d21c17 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -260,6 +260,9 @@
         Update the packaged version of the Tomcat Migration Tool for Jakarta EE
         to 1.0.9. (markt)
       </update>
+      <update>
+        Update the internal fork of Commons Pool to 2.12.1. (markt)
+      </update>
     </changelog>
   </subsection>
 </section>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org


Reply via email to