Skip to content

Commit b1b939a

Browse files
committed
[POOL-422]
org.apache.commons.pool3.impl.GenericObjectPool.create(Duration) duration computation doesn't match 2.x
2 parents d6da62d + 8e3a298 commit b1b939a

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/changes/changes.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ The <action> type attribute can be add,update,fix,remove.
5454
<!-- FIX -->
5555
<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>
5656
<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>
57+
<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>
5758
<!-- REMOVE -->
5859
<action dev="ggregory" type="remove">Deprecations from version 2.x have been removed.</action>
5960
<!-- UPDATE -->

src/main/java/org/apache/commons/pool3/impl/GenericObjectPool.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -501,13 +501,13 @@ public void close() {
501501
* If the factory makeObject returns null, this method throws a NullPointerException.
502502
* </p>
503503
*
504-
* @param maxWaitDuration The time to wait for an object to become available.
504+
* @param maxWaitDurationRequest The time to wait for an object to become available.
505505
* @return The new wrapped pooled object or null.
506506
* @throws E if the object factory's {@code makeObject} fails
507507
*/
508-
private PooledObject<T> create(final Duration maxWaitDuration) throws E {
508+
private PooledObject<T> create(final Duration maxWaitDurationRequest) throws E {
509509
final Instant startInstant = Instant.now();
510-
Duration remainingWaitDuration = maxWaitDuration.isNegative() ? Duration.ZERO : maxWaitDuration;
510+
final Duration maxWaitDuration = maxWaitDurationRequest.isNegative() ? Duration.ZERO : maxWaitDurationRequest;
511511
int localMaxTotal = getMaxTotal();
512512
// This simplifies the code later in this method
513513
if (localMaxTotal < 0) {
@@ -522,7 +522,7 @@ private PooledObject<T> create(final Duration maxWaitDuration) throws E {
522522
Boolean create = null;
523523
while (create == null) {
524524
// remainingWaitDuration handles spurious wakeup from wait().
525-
remainingWaitDuration = remainingWaitDuration.minus(durationSince(startInstant));
525+
final Duration remainingWaitDuration = maxWaitDuration.minus(durationSince(startInstant));
526526
synchronized (makeObjectCountLock) {
527527
final long newCreateCount = createCount.incrementAndGet();
528528
if (newCreateCount > localMaxTotal) {

0 commit comments

Comments
 (0)