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:04:01 UTC
(httpcomponents-core) branch master updated: StrictConnPool: Fix FIFO implementation
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 a777eec54 StrictConnPool: Fix FIFO implementation
a777eec54 is described below
commit a777eec54b7a23f7964e53d6d6ca706c5cf81085
Author: Ryan Schmitt <rs...@apache.org>
AuthorDate: Wed Jan 28 18:47:41 2026 -0800
StrictConnPool: Fix FIFO implementation
---
.../java/org/apache/hc/core5/pool/StrictConnPool.java | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/pool/StrictConnPool.java b/httpcore5/src/main/java/org/apache/hc/core5/pool/StrictConnPool.java
index 0bc0c1b6d..f5c3e4285 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/pool/StrictConnPool.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/pool/StrictConnPool.java
@@ -157,7 +157,7 @@ public void close() {
}
private PerRoutePool<T, C> getPool(final T route) {
- return this.routeToPool.computeIfAbsent(route, r -> new PerRoutePool<>(route, this.disposalCallback));
+ return this.routeToPool.computeIfAbsent(route, r -> new PerRoutePool<>(route, this.disposalCallback, this.policy));
}
@Override
@@ -755,11 +755,13 @@ static class PerRoutePool<T, C extends ModalCloseable> {
private final Set<PoolEntry<T, C>> leased;
private final LinkedList<PoolEntry<T, C>> available;
private final DisposalCallback<C> disposalCallback;
+ private final PoolReusePolicy policy;
- PerRoutePool(final T route, final DisposalCallback<C> disposalCallback) {
+ PerRoutePool(final T route, final DisposalCallback<C> disposalCallback, final PoolReusePolicy policy) {
super();
this.route = route;
this.disposalCallback = disposalCallback;
+ this.policy = policy;
this.leased = new HashSet<>();
this.available = new LinkedList<>();
}
@@ -818,7 +820,16 @@ public void free(final PoolEntry<T, C> entry, final boolean reusable) {
final boolean found = this.leased.remove(entry);
Asserts.check(found, "Entry %s has not been leased from this pool", entry);
if (reusable) {
- this.available.addFirst(entry);
+ switch (this.policy) {
+ case LIFO:
+ this.available.addFirst(entry);
+ break;
+ case FIFO:
+ this.available.addLast(entry);
+ break;
+ default:
+ throw new IllegalStateException("Unexpected ConnPoolPolicy value: " + policy);
+ }
}
}