hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject [03/50] [abbrv] httpcomponents-core git commit: Corrected termination of pending commands by HTTP/1.1 stream duplexer
Date Tue, 09 May 2017 19:57:55 GMT
Corrected termination of pending commands by HTTP/1.1 stream duplexer

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk@1791943 13f79535-47bb-0310-9956-ffa450edef68


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

Branch: refs/heads/trunk
Commit: 9ae9ade8931014e10f3cdb8677507f3d274c357e
Parents: 572bbd3
Author: Oleg Kalnichevski <olegk@apache.org>
Authored: Wed Apr 19 16:39:53 2017 +0000
Committer: Oleg Kalnichevski <olegk@apache.org>
Committed: Wed Apr 19 16:39:53 2017 +0000

----------------------------------------------------------------------
 .../nio/AbstractHttp2StreamMultiplexer.java     |  1 +
 .../impl/nio/AbstractHttp1StreamDuplexer.java   | 30 +++++++++++++-------
 2 files changed, 21 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9ae9ade8/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 7a53353..61c7fb9 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
@@ -647,6 +647,7 @@ abstract class AbstractHttp2StreamMultiplexer implements HttpConnection
{
                         final ExecutionCommand executionCommand = (ExecutionCommand) command;
                         final AsyncClientExchangeHandler exchangeHandler = executionCommand.getExchangeHandler();
                         exchangeHandler.failed(cause);
+                        exchangeHandler.releaseResources();
                     } else {
                         command.cancel();
                     }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9ae9ade8/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 176350c..bbda5c8 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
@@ -57,6 +57,7 @@ import org.apache.hc.core5.http.impl.BasicHttpConnectionMetrics;
 import org.apache.hc.core5.http.impl.BasicHttpTransportMetrics;
 import org.apache.hc.core5.http.impl.CharCodingSupport;
 import org.apache.hc.core5.http.impl.ConnectionListener;
+import org.apache.hc.core5.http.nio.AsyncClientExchangeHandler;
 import org.apache.hc.core5.http.nio.CapacityChannel;
 import org.apache.hc.core5.http.nio.ContentDecoder;
 import org.apache.hc.core5.http.nio.ContentEncoder;
@@ -366,14 +367,13 @@ abstract class AbstractHttp1StreamDuplexer<IncomingMessage extends
HttpMessage,
         }
         if (connState.compareTo(ConnectionState.SHUTDOWN) >= 0) {
             ioSession.close();
-            cancelPendingCommands();
             releaseResources();
         }
     }
 
     public final void onTimeout() throws IOException, HttpException {
         if (!handleTimeout()) {
-            shutdownSession(new SocketTimeoutException());
+            onException(new SocketTimeoutException());
         }
     }
 
@@ -383,6 +383,20 @@ abstract class AbstractHttp1StreamDuplexer<IncomingMessage extends
HttpMessage,
         }
         try {
             shutdownSession(ex);
+            for (;;) {
+                final Command command = ioSession.getCommand();
+                if (command != null) {
+                    if (command instanceof ExecutionCommand) {
+                        final AsyncClientExchangeHandler exchangeHandler = ((ExecutionCommand)
command).getExchangeHandler();
+                        exchangeHandler.failed(ex);
+                        exchangeHandler.releaseResources();
+                    } else {
+                        command.cancel();
+                    }
+                } else {
+                    break;
+                }
+            }
         } catch (IOException ex2) {
             if (connectionListener != null) {
                 connectionListener.onError(this, ex2);
@@ -391,15 +405,7 @@ abstract class AbstractHttp1StreamDuplexer<IncomingMessage extends
HttpMessage,
     }
 
     public final void onDisconnect() {
-        cancelPendingCommands();
         disconnected();
-        releaseResources();
-        if (connectionListener != null) {
-            connectionListener.onDisconnect(this);
-        }
-    }
-
-    private void cancelPendingCommands() {
         for (;;) {
             final Command command = ioSession.getCommand();
             if (command != null) {
@@ -408,6 +414,10 @@ abstract class AbstractHttp1StreamDuplexer<IncomingMessage extends
HttpMessage,
                 break;
             }
         }
+        releaseResources();
+        if (connectionListener != null) {
+            connectionListener.onDisconnect(this);
+        }
     }
 
     void requestShutdown(final ShutdownType shutdownType) {


Mime
View raw message