hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject httpcomponents-core git commit: Set pending execution commands to failed instead of cancelled in case of premature connection termination
Date Wed, 07 Jun 2017 09:16:42 GMT
Repository: httpcomponents-core
Updated Branches:
  refs/heads/master 7d518b5f6 -> 12065472a


Set pending execution commands to failed instead of cancelled in case of premature connection
termination


Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/12065472
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/12065472
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/12065472

Branch: refs/heads/master
Commit: 12065472a137ab1d8db3e1103fa80c5da37efc50
Parents: 7d518b5
Author: Oleg Kalnichevski <olegk@apache.org>
Authored: Tue Jun 6 16:40:07 2017 +0200
Committer: Oleg Kalnichevski <olegk@apache.org>
Committed: Wed Jun 7 11:14:47 2017 +0200

----------------------------------------------------------------------
 .../core5/http2/impl/nio/AbstractHttp2StreamMultiplexer.java | 8 +++++++-
 .../apache/hc/core5/testing/nio/Http1IntegrationTest.java    | 5 ++---
 .../hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java  | 8 +++++++-
 3 files changed, 16 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/12065472/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2StreamMultiplexer.java
----------------------------------------------------------------------
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2StreamMultiplexer.java
b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2StreamMultiplexer.java
index 697560b..ed5a537 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2StreamMultiplexer.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2StreamMultiplexer.java
@@ -547,7 +547,13 @@ abstract class AbstractHttp2StreamMultiplexer implements HttpConnection
{
         for (;;) {
             final Command command = ioSession.getCommand();
             if (command != null) {
-                command.cancel();
+                if (command instanceof ExecutionCommand) {
+                    final AsyncClientExchangeHandler exchangeHandler = ((ExecutionCommand)
command).getExchangeHandler();
+                    exchangeHandler.failed(new ConnectionClosedException("Connection closed"));
+                    exchangeHandler.releaseResources();
+                } else {
+                    command.cancel();
+                }
             } else {
                 break;
             }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/12065472/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http1IntegrationTest.java
----------------------------------------------------------------------
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http1IntegrationTest.java
b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http1IntegrationTest.java
index 2c5f3b0..f76f857 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http1IntegrationTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http1IntegrationTest.java
@@ -1280,9 +1280,8 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase
{
 
         try {
             future3.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
-            Assert.fail("CancellationException expected");
-        } catch (final CancellationException ignore) {
-            Assert.assertTrue(future3.isCancelled());
+            Assert.fail("ExecutionException expected");
+        } catch (final ExecutionException ignore) {
         }
     }
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/12065472/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java
b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java
index 259de37..197ed1c 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java
@@ -413,7 +413,13 @@ abstract class AbstractHttp1StreamDuplexer<IncomingMessage extends
HttpMessage,
         for (;;) {
             final Command command = ioSession.getCommand();
             if (command != null) {
-                command.cancel();
+                if (command instanceof ExecutionCommand) {
+                    final AsyncClientExchangeHandler exchangeHandler = ((ExecutionCommand)
command).getExchangeHandler();
+                    exchangeHandler.failed(new ConnectionClosedException("Connection closed"));
+                    exchangeHandler.releaseResources();
+                } else {
+                    command.cancel();
+                }
             } else {
                 break;
             }


Mime
View raw message