You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by rs...@apache.org on 2026/01/29 17:05:00 UTC
(httpcomponents-core) branch master updated: LaxConnPool: Loop over expired connections
This is an automated email from the ASF dual-hosted git repository.
rschmitt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git
The following commit(s) were added to refs/heads/master by this push:
new 1656006dc LaxConnPool: Loop over expired connections
1656006dc is described below
commit 1656006dce68b75572c8a8019f0f07a5bf19d84e
Author: Ryan Schmitt <rs...@apache.org>
AuthorDate: Wed Jan 28 18:52:33 2026 -0800
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.
---
httpcore5/src/main/java/org/apache/hc/core5/pool/LaxConnPool.java | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/pool/LaxConnPool.java b/httpcore5/src/main/java/org/apache/hc/core5/pool/LaxConnPool.java
index 15405ac8b..c3e682b66 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/pool/LaxConnPool.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/pool/LaxConnPool.java
@@ -442,13 +442,11 @@ private PoolEntry<T, C> getAvailableEntry(final Object state) {
final PoolEntry<T, C> entry = ref.getReference();
if (ref.compareAndSet(entry, entry, false, true)) {
it.remove();
- if (entry.getExpiryDeadline().isExpired()) {
+ if (entry.getExpiryDeadline().isExpired() || !Objects.equals(entry.getState(), state)) {
entry.discardConnection(CloseMode.GRACEFUL);
+ } else {
+ return entry;
}
- if (!Objects.equals(entry.getState(), state)) {
- entry.discardConnection(CloseMode.GRACEFUL);
- }
- return entry;
}
}
return null;