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 9e7a8ebb67..a3d5b6f2d7 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 @@ public void acquireEndpoint( 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;