This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-pool.git
The following commit(s) were added to refs/heads/master by this push: new b3036dfd org.apache.commons.pool3.impl.GenericObjectPool.create(Duration) duration computation doesn't match 2.x b3036dfd is described below commit b3036dfda4f87120fba7beaee00aad689f17425c Author: Gary D. Gregory <garydgreg...@gmail.com> AuthorDate: Sat Jun 7 08:36:31 2025 -0400 org.apache.commons.pool3.impl.GenericObjectPool.create(Duration) duration computation doesn't match 2.x See also PR #409 from shengulong --- src/changes/changes.xml | 1 + .../java/org/apache/commons/pool3/impl/GenericObjectPool.java | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index bad1ac91..8b70e7fd 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -54,6 +54,7 @@ The <action> type attribute can be add,update,fix,remove. <!-- FIX --> <action type="fix" dev="ggregory" due-to="Gary Gregory">Remove -nouses directive from maven-bundle-plugin. OSGi package imports now state 'uses' definitions for package imports, this doesn't affect JPMS (from org.apache.commons:commons-parent:80).</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.pool3.PoolUtils$ErodingFactor] At PoolUtils.java:[line 101] AT_NONATOMIC_OPERATIONS_ON_SHARED_VARIABLE.</action> + <action type="fix" dev="ggregory" due-to="shengulong, Gary Gregory" issue="POOL-422">org.apache.commons.pool3.impl.GenericObjectPool.create(Duration) duration computation doesn't match 2.x. See also PR #409 from shengulong.</action> <!-- REMOVE --> <action dev="ggregory" type="remove">Deprecations from version 2.x have been removed.</action> <!-- UPDATE --> diff --git a/src/main/java/org/apache/commons/pool3/impl/GenericObjectPool.java b/src/main/java/org/apache/commons/pool3/impl/GenericObjectPool.java index 4972e61a..12d9decd 100644 --- a/src/main/java/org/apache/commons/pool3/impl/GenericObjectPool.java +++ b/src/main/java/org/apache/commons/pool3/impl/GenericObjectPool.java @@ -501,13 +501,13 @@ public class GenericObjectPool<T, E extends Exception> extends BaseGenericObject * If the factory makeObject returns null, this method throws a NullPointerException. * </p> * - * @param maxWaitDuration The time to wait for an object to become available. + * @param maxWaitDurationRequest The time to wait for an object to become available. * @return The new wrapped pooled object or null. * @throws E if the object factory's {@code makeObject} fails */ - private PooledObject<T> create(final Duration maxWaitDuration) throws E { + private PooledObject<T> create(final Duration maxWaitDurationRequest) throws E { 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) { @@ -522,7 +522,7 @@ public class GenericObjectPool<T, E extends Exception> extends BaseGenericObject Boolean create = null; while (create == null) { // remainingWaitDuration handles spurious wakeup from wait(). - remainingWaitDuration = remainingWaitDuration.minus(durationSince(startInstant)); + final Duration remainingWaitDuration = maxWaitDuration.minus(durationSince(startInstant)); synchronized (makeObjectCountLock) { final long newCreateCount = createCount.incrementAndGet(); if (newCreateCount > localMaxTotal) {