From a46c9e56568b67cff95454c60daf80f3b14c4319 Mon Sep 17 00:00:00 2001 From: Oleg Kalnichevski Date: Thu, 30 Nov 2023 13:21:52 +0100 Subject: [PATCH] Added missing #disconnectEndpoint method to AsyncConnectExec --- .../apache/hc/client5/http/async/AsyncExecRuntime.java | 5 +++++ .../http/impl/async/InternalH2AsyncExecRuntime.java | 8 ++++++++ .../http/impl/async/InternalHttpAsyncExecRuntime.java | 8 ++++++++ 3 files changed, 21 insertions(+) diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/async/AsyncExecRuntime.java b/httpclient5/src/main/java/org/apache/hc/client5/http/async/AsyncExecRuntime.java index 237a5e264..a82c778dd 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/async/AsyncExecRuntime.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/async/AsyncExecRuntime.java @@ -106,6 +106,11 @@ public interface AsyncExecRuntime { HttpClientContext context, FutureCallback callback); + /** + * Disconnects the local endpoint from the initial hop in the connection route. + */ + void disconnectEndpoint(); + /** * Upgrades transport security of the active connection by using the TLS security protocol. * diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalH2AsyncExecRuntime.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalH2AsyncExecRuntime.java index e6879171f..e4ebbcecd 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalH2AsyncExecRuntime.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalH2AsyncExecRuntime.java @@ -215,6 +215,14 @@ class InternalH2AsyncExecRuntime implements AsyncExecRuntime { } + @Override + public void disconnectEndpoint() { + final Endpoint endpoint = sessionRef.get(); + if (endpoint != null) { + endpoint.session.close(CloseMode.GRACEFUL); + } + } + @Override public void upgradeTls(final HttpClientContext context) { throw new UnsupportedOperationException(); diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalHttpAsyncExecRuntime.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalHttpAsyncExecRuntime.java index a7f5d65b1..bf58c51be 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalHttpAsyncExecRuntime.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalHttpAsyncExecRuntime.java @@ -235,6 +235,14 @@ class InternalHttpAsyncExecRuntime implements AsyncExecRuntime { } + @Override + public void disconnectEndpoint() { + final AsyncConnectionEndpoint endpoint = endpointRef.get(); + if (endpoint != null) { + endpoint.close(CloseMode.GRACEFUL); + } + } + @Override public void upgradeTls(final HttpClientContext context) { upgradeTls(context, null);