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

ggregory pushed a commit to branch POOL_2_X
in repository https://gitbox.apache.org/repos/asf/commons-pool.git


The following commit(s) were added to refs/heads/POOL_2_X by this push:
     new 34812b1b 
org.apache.commons.pool2.impl.GenericObjectPool.create(Duration) should 
normalize a negative duration to zero
34812b1b is described below

commit 34812b1bdaef96cfb1ea650a8ba07b41a7c35d77
Author: Gary D. Gregory <garydgreg...@gmail.com>
AuthorDate: Sat Jun 7 08:28:18 2025 -0400

    org.apache.commons.pool2.impl.GenericObjectPool.create(Duration) should
    normalize a negative duration to zero
---
 src/changes/changes.xml                                        |  1 +
 .../java/org/apache/commons/pool2/impl/GenericObjectPool.java  | 10 +++++-----
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 11346422..4c4b1abd 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -60,6 +60,7 @@ The <action> type attribute can be add,update,fix,remove.
     </action>
     <action type="fix" dev="ggregory" due-to="Wei Guo, Gary Gregory">Fix site 
link from the About page to the Download page, see also #387.</action>
     <action type="fix" dev="ggregory" due-to="Gary Gregory">Operation on the 
"idleHighWaterMark" shared variable in "ErodingFactor" class is not atomic 
[org.apache.commons.pool2.PoolUtils$ErodingFactor] At PoolUtils.java:[line 98] 
AT_NONATOMIC_OPERATIONS_ON_SHARED_VARIABLE.</action>
+    <action type="fix" dev="ggregory" due-to="Gary 
Gregory">org.apache.commons.pool2.impl.GenericObjectPool.create(Duration) 
should normalize a negative duration to zero.</action>
     <!-- ADD -->
     <!-- UPDATE -->
     <action type="update" dev="ggregory" due-to="Gary Gregory">Bump 
org.apache.commons:commons-parent from 79 to 81.</action>
diff --git a/src/main/java/org/apache/commons/pool2/impl/GenericObjectPool.java 
b/src/main/java/org/apache/commons/pool2/impl/GenericObjectPool.java
index c3da188f..d40f67fb 100644
--- a/src/main/java/org/apache/commons/pool2/impl/GenericObjectPool.java
+++ b/src/main/java/org/apache/commons/pool2/impl/GenericObjectPool.java
@@ -494,13 +494,13 @@ 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 capacity to create
+     * @param maxWaitDurationRequest The time to wait for capacity to create.
      * @return The new wrapped pooled object or null.
-     * @throws Exception if the object factory's {@code makeObject} fails
+     * @throws Exception if the object factory's {@code makeObject} fails.
      */
-    private PooledObject<T> create(final Duration maxWaitDuration) throws 
Exception {
+    private PooledObject<T> create(final Duration maxWaitDurationRequest) 
throws Exception {
         final Instant startInstant = Instant.now();
-        Duration remainingWaitDuration = maxWaitDuration.isNegative() ? 
Duration.ZERO : maxWaitDuration;
+        final Duration maxWaitDuration = maxWaitDurationRequest.isNegative() ? 
Duration.ZERO : maxWaitDurationRequest;
         int localMaxTotal = getMaxTotal();
         // This simplifies the code later in this method
         if (localMaxTotal < 0) {
@@ -515,7 +515,7 @@ public class GenericObjectPool<T> extends 
BaseGenericObjectPool<T>
         Boolean create = null;
         while (create == null) {
             // remainingWaitDuration handles spurious wakeup from wait().
-            remainingWaitDuration = 
maxWaitDuration.minus(durationSince(startInstant));
+            final Duration remainingWaitDuration = 
maxWaitDuration.minus(durationSince(startInstant));
             synchronized (makeObjectCountLock) {
                 final long newCreateCount = createCount.incrementAndGet();
                 if (newCreateCount > localMaxTotal) {

Reply via email to