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 2017/04/19 16:39:53 UTC
svn commit: r1791943 - in /httpcomponents/httpcore/trunk:
httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2StreamMultiplexer.java
httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java
Author: olegk
Date: Wed Apr 19 16:39:53 2017
New Revision: 1791943
URL: http://svn.apache.org/viewvc?rev=1791943&view=rev
Log:
Corrected termination of pending commands by HTTP/1.1 stream duplexer
Modified:
httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2StreamMultiplexer.java
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java
Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2StreamMultiplexer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2StreamMultiplexer.java?rev=1791943&r1=1791942&r2=1791943&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2StreamMultiplexer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2StreamMultiplexer.java Wed Apr 19 16:39:53 2017
@@ -647,6 +647,7 @@ abstract class AbstractHttp2StreamMultip
final ExecutionCommand executionCommand = (ExecutionCommand) command;
final AsyncClientExchangeHandler exchangeHandler = executionCommand.getExchangeHandler();
exchangeHandler.failed(cause);
+ exchangeHandler.releaseResources();
} else {
command.cancel();
}
Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java?rev=1791943&r1=1791942&r2=1791943&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java Wed Apr 19 16:39:53 2017
@@ -57,6 +57,7 @@ import org.apache.hc.core5.http.impl.Bas
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 AbstractHttp1StreamDuplex
}
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 AbstractHttp1StreamDuplex
}
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 AbstractHttp1StreamDuplex
}
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 AbstractHttp1StreamDuplex
break;
}
}
+ releaseResources();
+ if (connectionListener != null) {
+ connectionListener.onDisconnect(this);
+ }
}
void requestShutdown(final ShutdownType shutdownType) {