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 2021/04/28 14:38:05 UTC

[httpcomponents-client] branch 5.0.x updated: Extra sage-guards for concurrent connection endpoint acquisition and request execution cancellation

This is an automated email from the ASF dual-hosted git repository.

olegk pushed a commit to branch 5.0.x
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git


The following commit(s) were added to refs/heads/5.0.x by this push:
     new 2ee6454  Extra sage-guards for concurrent connection endpoint acquisition and request execution cancellation
2ee6454 is described below

commit 2ee645451aea8a42e49fe602ddfcfecbb80b57ce
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Wed Apr 28 16:31:16 2021 +0200

    Extra sage-guards for concurrent connection endpoint acquisition and request execution cancellation
---
 .../apache/hc/client5/http/impl/classic/InternalExecRuntime.java    | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

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 abd8afe..299f56d 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
@@ -103,11 +103,11 @@ class InternalExecRuntime implements ExecRuntime, Cancellable {
             final LeaseRequest connRequest = manager.lease(id, route, connectionRequestTimeout, object);
             state = object;
             if (cancellableDependency != null) {
+                cancellableDependency.setDependency(connRequest);
                 if (cancellableDependency.isCancelled()) {
                     connRequest.cancel();
                     throw new RequestFailedException("Request aborted");
                 }
-                cancellableDependency.setDependency(connRequest);
             }
             try {
                 final ConnectionEndpoint connectionEndpoint = connRequest.get(connectionRequestTimeout);
@@ -115,6 +115,10 @@ class InternalExecRuntime implements ExecRuntime, Cancellable {
                 reusable = connectionEndpoint.isConnected();
                 if (cancellableDependency != null) {
                     cancellableDependency.setDependency(this);
+                    if (cancellableDependency.isCancelled()) {
+                        cancel();
+                        throw new RequestFailedException("Request aborted");
+                    }
                 }
                 if (log.isDebugEnabled()) {
                     log.debug("{}: acquired endpoint {}", id, ConnPoolSupport.getId(connectionEndpoint));