From fe6b3604b8025dd837c9645eb09e04737c765b3a Mon Sep 17 00:00:00 2001 From: Arturo Bernal Date: Thu, 13 Apr 2023 08:33:58 +0200 Subject: [PATCH] shutdown whenComplete instead. --- .../nio/HappyEyeballsV2AsyncClientConnectionOperator.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/HappyEyeballsV2AsyncClientConnectionOperator.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/HappyEyeballsV2AsyncClientConnectionOperator.java index 8e8542a9e..f41dab82d 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/HappyEyeballsV2AsyncClientConnectionOperator.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/HappyEyeballsV2AsyncClientConnectionOperator.java @@ -419,7 +419,6 @@ public Future connect( // If there is an exception, complete the connectionFuture exceptionally with the exception connectionFuture.completeExceptionally(new ConnectException("Failed to connect to any address for " + host)); } - shutdownSchedulerIfTasksCompleted(); // Invoke the callback if provided if (callback != null) { connectionFuture.whenComplete((conn, ex) -> { @@ -439,7 +438,9 @@ public Future connect( callback.failed(new Exception(e)); } return null; - }); + + }).whenComplete((result, ex) -> shutdownSchedulerIfTasksCompleted()); + return connectionFuture; }