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 2019/03/07 08:20:50 UTC

[httpcomponents-client] 02/04: Bug fix: main async request execution handlers to release teh associated response consumer upon exception

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

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

commit 39023dfed12a3311efa04c4ef738f0cad50d5b86
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Thu Mar 7 08:41:44 2019 +0100

    Bug fix: main async request execution handlers to release teh associated response consumer upon exception
---
 .../apache/hc/client5/http/impl/async/Http2AsyncMainClientExec.java   | 4 ++++
 .../apache/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 4d2b52f..422ce77 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 72dbbc4..e558989 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);
             }