Add BaseGenericObjectPool.{get|set}MaxWaitDuration(Duration) and
deprecate {get|set}MaxWaitMillis(long).

Add BaseObjectPoolConfig.{get|set}MaxWaitDuration(Duration) and
deprecate {get|set}MaxWaitMillis(long).
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 0caa9b1..073cd4c 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -57,7 +57,13 @@
       - TrackedUse#getLastUsedInstant()

     </action>

     <action dev="ggregory" type="add" due-to="Gary Gregory">

-      Add BaseObjectPoolConfig.setEvictorShutdownTimeout(Duration), setEvictorShutdownTimeoutMillis(Duration).

+      Add BaseObjectPoolConfig.{get|set}EvictorShutdownTimeout(Duration), {get|set}EvictorShutdownTimeoutMillis(Duration).

+    </action>

+    <action dev="ggregory" type="add" due-to="Gary Gregory">

+      Add BaseGenericObjectPool.{get|set}MaxWaitDuration(Duration) and deprecate {get|set}MaxWaitMillis(long).

+    </action>

+    <action dev="ggregory" type="add" due-to="Gary Gregory">

+      Add BaseObjectPoolConfig.{get|set}MaxWaitDuration(Duration) and deprecate {get|set}MaxWaitMillis(long).

     </action>

     <!-- FIXES -->

     <action dev="ggregory" type="fix" due-to="Gary Gregory">

diff --git a/src/main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java b/src/main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java
index 3eb5f6f..025c041 100644
--- a/src/main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java
+++ b/src/main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java
@@ -316,7 +316,7 @@
     // Configuration attributes

     private volatile int maxTotal = GenericKeyedObjectPoolConfig.DEFAULT_MAX_TOTAL;

     private volatile boolean blockWhenExhausted = BaseObjectPoolConfig.DEFAULT_BLOCK_WHEN_EXHAUSTED;

-    private volatile Duration maxWait = BaseObjectPoolConfig.DEFAULT_MAX_WAIT;

+    private volatile Duration maxWaitDuration = BaseObjectPoolConfig.DEFAULT_MAX_WAIT;

     private volatile boolean lifo = BaseObjectPoolConfig.DEFAULT_LIFO;

     private final boolean fairness;

     private volatile boolean testOnCreate = BaseObjectPoolConfig.DEFAULT_TEST_ON_CREATE;

@@ -592,7 +592,7 @@
     }

 

     /**

-     * The maximum time a thread has waited to borrow objects from the pool.

+     * Gets the maximum time a thread has waited to borrow objects from the pool.

      * @return maximum wait time in milliseconds since the pool was created

      */

     public final long getMaxBorrowWaitTimeMillis() {

@@ -615,6 +615,24 @@
     }

 

     /**

+     * Gets the maximum duration the

+     * {@code borrowObject()} method should block before throwing an

+     * exception when the pool is exhausted and

+     * {@link #getBlockWhenExhausted} is true. When less than 0, the

+     * {@code borrowObject()} method may block indefinitely.

+     *

+     * @return the maximum number of milliseconds {@code borrowObject()}

+     *         will block.

+     *

+     * @see #setMaxWaitDuration

+     * @see #setBlockWhenExhausted

+     * @since 2.11.0

+     */

+    public final Duration getMaxWaitDuration() {

+        return maxWaitDuration;

+    }

+

+    /**

      * Gets the maximum amount of time (in milliseconds) the

      * {@code borrowObject()} method should block before throwing an

      * exception when the pool is exhausted and

@@ -624,11 +642,12 @@
      * @return the maximum number of milliseconds {@code borrowObject()}

      *         will block.

      *

-     * @see #setMaxWaitMillis

+     * @see #setMaxWaitDuration

      * @see #setBlockWhenExhausted

+     * @deprecated Use {@link #getMaxWaitDuration()}.

      */

     public final long getMaxWaitMillis() {

-        return maxWait.toMillis();

+        return maxWaitDuration.toMillis();

     }

 

     /**

@@ -1009,7 +1028,7 @@
      */

     protected void setConfig(final BaseObjectPoolConfig<T> config) {

         setLifo(config.getLifo());

-        setMaxWaitMillis(config.getMaxWaitMillis());

+        setMaxWaitDuration(config.getMaxWaitDuration());

         setBlockWhenExhausted(config.getBlockWhenExhausted());

         setTestOnCreate(config.getTestOnCreate());

         setTestOnBorrow(config.getTestOnBorrow());

@@ -1166,6 +1185,25 @@
     }

 

     /**

+     * Sets the maximum duration the

+     * {@code borrowObject()} method should block before throwing an

+     * exception when the pool is exhausted and

+     * {@link #getBlockWhenExhausted} is true. When less than 0, the

+     * {@code borrowObject()} method may block indefinitely.

+     *

+     * @param maxWaitDuration the maximum duration

+     *                      {@code borrowObject()} will block or negative

+     *                      for indefinitely.

+     *

+     * @see #getMaxWaitDuration

+     * @see #setBlockWhenExhausted

+     * @since 2.11.0

+     */

+    public final void setMaxWaitDuration(final Duration maxWaitDuration) {

+        this.maxWaitDuration = PoolImplUtils.nonNull(maxWaitDuration, BaseObjectPoolConfig.DEFAULT_MAX_WAIT);

+    }

+

+    /**

      * Sets the maximum amount of time (in milliseconds) the

      * {@code borrowObject()} method should block before throwing an

      * exception when the pool is exhausted and

@@ -1176,11 +1214,13 @@
      *                      {@code borrowObject()} will block or negative

      *                      for indefinitely.

      *

-     * @see #getMaxWaitMillis

+     * @see #getMaxWaitDuration

      * @see #setBlockWhenExhausted

+     * @deprecated Use {@link #setMaxWaitDuration}.

      */

+    @Deprecated

     public final void setMaxWaitMillis(final long maxWaitMillis) {

-        this.maxWait = Duration.ofMillis(maxWaitMillis);

+        setMaxWaitDuration(Duration.ofMillis(maxWaitMillis));

     }

 

     /**

@@ -1481,7 +1521,7 @@
         builder.append(", blockWhenExhausted=");

         builder.append(blockWhenExhausted);

         builder.append(", maxWaitMillis=");

-        builder.append(maxWait);

+        builder.append(maxWaitDuration);

         builder.append(", lifo=");

         builder.append(lifo);

         builder.append(", fairness=");

@@ -1548,13 +1588,13 @@
      * Updates statistics after an object is borrowed from the pool.

      *

      * @param p object borrowed from the pool

-     * @param waitTime time (in milliseconds) that the borrowing thread had to wait

+     * @param waitDuration time (in milliseconds) that the borrowing thread had to wait

      */

-    final void updateStatsBorrow(final PooledObject<T> p, final Duration waitTime) {

+    final void updateStatsBorrow(final PooledObject<T> p, final Duration waitDuration) {

         borrowedCount.incrementAndGet();

         idleTimes.add(p.getIdleTime());

-        waitTimes.add(waitTime);

-        final long waitTimeMillis = waitTime.toMillis();

+        waitTimes.add(waitDuration);

+        final long waitTimeMillis = waitDuration.toMillis();

 

         // lock-free optimistic-locking maximum

         long currentMaxMillis;

diff --git a/src/main/java/org/apache/commons/pool2/impl/BaseObjectPoolConfig.java b/src/main/java/org/apache/commons/pool2/impl/BaseObjectPoolConfig.java
index ab7f0e3..7d3c6b6 100644
--- a/src/main/java/org/apache/commons/pool2/impl/BaseObjectPoolConfig.java
+++ b/src/main/java/org/apache/commons/pool2/impl/BaseObjectPoolConfig.java
@@ -49,15 +49,15 @@
 
     /**
      * The default value for the {@code maxWait} configuration attribute.
-     * @see GenericObjectPool#getMaxWaitMillis()
-     * @see GenericKeyedObjectPool#getMaxWaitMillis()
+     * @see GenericObjectPool#getMaxWaitDuration()
+     * @see GenericKeyedObjectPool#getMaxWaitDuration()
      */
     public static final long DEFAULT_MAX_WAIT_MILLIS = -1L;
 
     /**
      * The default value for the {@code maxWait} configuration attribute.
-     * @see GenericObjectPool#getMaxWaitMillis()
-     * @see GenericKeyedObjectPool#getMaxWaitMillis()
+     * @see GenericObjectPool#getMaxWaitDuration()
+     * @see GenericKeyedObjectPool#getMaxWaitDuration()
      * @since 2.10.0
      */
     public static final Duration DEFAULT_MAX_WAIT = Duration.ofMillis(DEFAULT_MAX_WAIT_MILLIS);
@@ -222,7 +222,7 @@
 
     private boolean fairness = DEFAULT_FAIRNESS;
 
-    private Duration maxWaitMillis = DEFAULT_MAX_WAIT;
+    private Duration maxWaitDuration = DEFAULT_MAX_WAIT;
 
     private Duration minEvictableIdleTime = DEFAULT_MIN_EVICTABLE_IDLE_TIME;
 
@@ -401,11 +401,27 @@
      * @return  The current setting of {@code maxWait} for this
      *          configuration instance
      *
+     * @see GenericObjectPool#getMaxWaitDuration()
+     * @see GenericKeyedObjectPool#getMaxWaitDuration()
+     * @since 2.11.0
+     */
+    public Duration getMaxWaitDuration() {
+        return maxWaitDuration;
+    }
+
+    /**
+     * Gets the value for the {@code maxWait} configuration attribute for pools
+     * created with this configuration instance.
+     *
+     * @return  The current setting of {@code maxWait} for this
+     *          configuration instance
+     *
      * @see GenericObjectPool#getMaxWaitMillis()
      * @see GenericKeyedObjectPool#getMaxWaitMillis()
+     * @deprecated Use {@link #getMaxWaitDuration()}.
      */
     public long getMaxWaitMillis() {
-        return maxWaitMillis.toMillis();
+        return maxWaitDuration.toMillis();
     }
 
     /**
@@ -740,11 +756,25 @@
      * @param maxWaitMillis The new setting of {@code maxWaitMillis}
      *        for this configuration instance
      *
-     * @see GenericObjectPool#getMaxWaitMillis()
-     * @see GenericKeyedObjectPool#getMaxWaitMillis()
+     * @see GenericObjectPool#getMaxWaitDuration()
+     * @see GenericKeyedObjectPool#getMaxWaitDuration()
      */
     public void setMaxWaitMillis(final long maxWaitMillis) {
-        this.maxWaitMillis = Duration.ofMillis(maxWaitMillis);
+        setMaxWaitDuration(Duration.ofMillis(maxWaitMillis));
+    }
+
+    /**
+     * Sets the value for the {@code maxWait} configuration attribute for pools
+     * created with this configuration instance.
+     *
+     * @param maxWaitDuration The new setting of {@code maxWaitDuration}
+     *        for this configuration instance
+     *
+     * @see GenericObjectPool#getMaxWaitDuration()
+     * @see GenericKeyedObjectPool#getMaxWaitDuration()
+     */
+    public void setMaxWaitDuration(final Duration maxWaitDuration) {
+        this.maxWaitDuration = PoolImplUtils.nonNull(maxWaitDuration, DEFAULT_MAX_WAIT);;
     }
 
     /**
@@ -926,7 +956,7 @@
         builder.append(", fairness=");
         builder.append(fairness);
         builder.append(", maxWaitMillis=");
-        builder.append(maxWaitMillis);
+        builder.append(maxWaitDuration);
         builder.append(", minEvictableIdleTime=");
         builder.append(minEvictableIdleTime);
         builder.append(", softMinEvictableIdleTime=");
diff --git a/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java b/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
index ed5f206..a5ae8aa 100644
--- a/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
+++ b/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
@@ -344,13 +344,13 @@
 
     /**
      * Equivalent to <code>{@link #borrowObject(Object, long) borrowObject}(key,
-     * {@link #getMaxWaitMillis()})</code>.
+     * {@link #getMaxWaitDuration()})</code>.
      * <p>
      * {@inheritDoc}
      */
     @Override
     public T borrowObject(final K key) throws Exception {
-        return borrowObject(key, getMaxWaitMillis());
+        return borrowObject(key, getMaxWaitDuration().toMillis());
     }
 
 
diff --git a/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java b/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java
index e9ce2ad..b35cbb2 100644
--- a/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java
+++ b/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java
@@ -607,7 +607,8 @@
                 "whenExhaustedAction");
         assertEquals(expected.getMaxTotal(), actual.getMaxTotal(), "maxTotal");
         assertEquals(expected.getMaxIdle(), actual.getMaxIdle(), "maxIdle");
-        assertEquals(expected.getMaxWaitMillis(), actual.getMaxWaitMillis(), "maxWait");
+        assertEquals(expected.getMaxWaitMillis(), actual.getMaxWaitMillis(), "maxWaitDuration");
+        assertEquals(expected.getMaxWaitDuration(), actual.getMaxWaitDuration(), "maxWaitDuration");
         assertEquals(expected.getMinEvictableIdleTimeMillis(), actual.getMinEvictableIdleTimeMillis(),
                 "minEvictableIdleTimeMillis");
         assertEquals(expected.getMinEvictableIdleTime(), actual.getMinEvictableIdleTime(),