From 39023dfed12a3311efa04c4ef738f0cad50d5b86 Mon Sep 17 00:00:00 2001 From: Oleg Kalnichevski Date: Thu, 7 Mar 2019 08:41:44 +0100 Subject: [PATCH] Bug fix: main async request execution handlers to release teh associated response consumer upon exception --- .../hc/client5/http/impl/async/Http2AsyncMainClientExec.java | 4 ++++ .../hc/client5/http/impl/async/HttpAsyncMainClientExec.java | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/Http2AsyncMainClientExec.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/Http2AsyncMainClientExec.java index 4d2b52ff8..422ce7735 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/Http2AsyncMainClientExec.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/Http2AsyncMainClientExec.java @@ -100,6 +100,10 @@ public class Http2AsyncMainClientExec implements AsyncExecChainHandler { @Override public void failed(final Exception cause) { + final AsyncDataConsumer entityConsumer = entityConsumerRef.getAndSet(null); + if (entityConsumer != null) { + entityConsumer.releaseResources(); + } execRuntime.markConnectionNonReusable(); asyncExecCallback.failed(cause); } 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 72dbbc48e..e558989c5 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 @@ -116,6 +116,10 @@ class HttpAsyncMainClientExec implements AsyncExecChainHandler { @Override public void failed(final Exception cause) { + final AsyncDataConsumer entityConsumer = entityConsumerRef.getAndSet(null); + if (entityConsumer != null) { + entityConsumer.releaseResources(); + } execRuntime.markConnectionNonReusable(); asyncExecCallback.failed(cause); }