From 3fe6a8bcdf0f49003290efea557ce650f2f41aac Mon Sep 17 00:00:00 2001 From: Oleg Kalnichevski Date: Wed, 17 Aug 2022 18:39:05 +0200 Subject: [PATCH] HTTPCLIENT-2231: a race condition in the main async exec when the request execution on an I/O thread is faster then execution pipeline management on the client thread --- .../hc/client5/http/impl/async/HttpAsyncMainClientExec.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncMainClientExec.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncMainClientExec.java index 3e904342b..86eff6164 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncMainClientExec.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncMainClientExec.java @@ -133,7 +133,9 @@ class HttpAsyncMainClientExec implements AsyncExecChainHandler { @Override public void cancel() { - failed(new InterruptedIOException()); + if (messageCountDown.get() > 0) { + failed(new InterruptedIOException()); + } } @Override