From 9cde791f35c21e1bcd01967d64f78d71cf790d86 Mon Sep 17 00:00:00 2001 From: Bryan Keller Date: Mon, 14 Nov 2022 07:54:48 -0800 Subject: [PATCH] Cancel connection request on exception --- .../hc/client5/http/impl/classic/InternalExecRuntime.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/InternalExecRuntime.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/InternalExecRuntime.java index 9e7a8ebb6..a3d5b6f2d 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/InternalExecRuntime.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/InternalExecRuntime.java @@ -116,11 +116,14 @@ class InternalExecRuntime implements ExecRuntime, Cancellable { log.debug("{} acquired endpoint {}", id, ConnPoolSupport.getId(connectionEndpoint)); } } catch(final TimeoutException ex) { + connRequest.cancel(); throw new ConnectionRequestTimeoutException(ex.getMessage()); } catch(final InterruptedException interrupted) { + connRequest.cancel(); Thread.currentThread().interrupt(); throw new RequestFailedException("Request aborted", interrupted); } catch(final ExecutionException ex) { + connRequest.cancel(); Throwable cause = ex.getCause(); if (cause == null) { cause = ex;