You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2024/01/30 16:07:21 UTC
(httpcomponents-client) 01/01: HTTPCLIENT-2316: BasicHttpClientConnectionManager incorrectly re-uses the released connection if it has been closed out by the protocol handler
This is an automated email from the ASF dual-hosted git repository.
olegk pushed a commit to branch HTTPCLIENT-2316
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git
commit 38d8d9b62eb6c6c6e8a47afd88cce4b43dc8d1b2
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Tue Jan 30 17:04:50 2024 +0100
HTTPCLIENT-2316: BasicHttpClientConnectionManager incorrectly re-uses the released connection if it has been closed out by the protocol handler
---
.../client5/http/impl/io/BasicHttpClientConnectionManager.java | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/BasicHttpClientConnectionManager.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/BasicHttpClientConnectionManager.java
index a89aa61f0..b52344ce3 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/BasicHttpClientConnectionManager.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/BasicHttpClientConnectionManager.java
@@ -69,6 +69,7 @@ import org.apache.hc.core5.io.CloseMode;
import org.apache.hc.core5.util.Args;
import org.apache.hc.core5.util.Asserts;
import org.apache.hc.core5.util.Deadline;
+import org.apache.hc.core5.util.Identifiable;
import org.apache.hc.core5.util.TimeValue;
import org.apache.hc.core5.util.Timeout;
import org.slf4j.Logger;
@@ -343,7 +344,7 @@ public class BasicHttpClientConnectionManager implements HttpClientConnectionMan
return;
}
try {
- if (keepAlive == null) {
+ if (keepAlive == null || conn == null) {
this.conn.close(CloseMode.GRACEFUL);
}
this.updated = System.currentTimeMillis();
@@ -482,7 +483,7 @@ public class BasicHttpClientConnectionManager implements HttpClientConnectionMan
.build();
}
- class InternalConnectionEndpoint extends ConnectionEndpoint {
+ class InternalConnectionEndpoint extends ConnectionEndpoint implements Identifiable {
private final HttpRoute route;
private final AtomicReference<ManagedHttpClientConnection> connRef;
@@ -492,6 +493,11 @@ public class BasicHttpClientConnectionManager implements HttpClientConnectionMan
this.connRef = new AtomicReference<>(conn);
}
+ @Override
+ public String getId() {
+ return id;
+ }
+
HttpRoute getRoute() {
return route;
}