Skip to content

Commit 1656006

Browse files
committed
LaxConnPool: Loop over expired connections
This change brings `LaxConnPool` into alignment with `StrictConnPool`, which loops over pool entries and discards expired ones as they are discovered, instead of returning them.
1 parent a777eec commit 1656006

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

httpcore5/src/main/java/org/apache/hc/core5/pool/LaxConnPool.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -442,13 +442,11 @@ private PoolEntry<T, C> getAvailableEntry(final Object state) {
442442
final PoolEntry<T, C> entry = ref.getReference();
443443
if (ref.compareAndSet(entry, entry, false, true)) {
444444
it.remove();
445-
if (entry.getExpiryDeadline().isExpired()) {
445+
if (entry.getExpiryDeadline().isExpired() || !Objects.equals(entry.getState(), state)) {
446446
entry.discardConnection(CloseMode.GRACEFUL);
447+
} else {
448+
return entry;
447449
}
448-
if (!Objects.equals(entry.getState(), state)) {
449-
entry.discardConnection(CloseMode.GRACEFUL);
450-
}
451-
return entry;
452450
}
453451
}
454452
return null;

0 commit comments

Comments
 (0)