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 2020/11/21 20:47:59 UTC
[httpcomponents-core] 01/05: Improved detection of disconnected
endpoints by HttpAsyncRequester
This is an automated email from the ASF dual-hosted git repository.
olegk pushed a commit to branch 5.0.x
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git
commit ea2996eca69a759c4c2e23c006788859961084a1
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Sat Nov 21 14:06:58 2020 +0100
Improved detection of disconnected endpoints by HttpAsyncRequester
---
.../hc/core5/http2/impl/nio/AbstractH2StreamMultiplexer.java | 2 +-
.../apache/hc/core5/http/impl/bootstrap/HttpAsyncRequester.java | 8 ++++++--
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractH2StreamMultiplexer.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractH2StreamMultiplexer.java
index 7524dea..a3961b2 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractH2StreamMultiplexer.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractH2StreamMultiplexer.java
@@ -686,9 +686,9 @@ abstract class AbstractH2StreamMultiplexer implements Identifiable, HttpConnecti
commitFrame(goAway);
}
}
- connState = ConnectionHandshake.SHUTDOWN;
} catch (final IOException ignore) {
} finally {
+ connState = ConnectionHandshake.SHUTDOWN;
final CloseMode closeMode;
if (cause instanceof ConnectionClosedException) {
closeMode = CloseMode.GRACEFUL;
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/bootstrap/HttpAsyncRequester.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/bootstrap/HttpAsyncRequester.java
index defebdd..5bd9006 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/bootstrap/HttpAsyncRequester.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/bootstrap/HttpAsyncRequester.java
@@ -43,6 +43,7 @@ import org.apache.hc.core5.function.Decorator;
import org.apache.hc.core5.http.ConnectionClosedException;
import org.apache.hc.core5.http.EntityDetails;
import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpConnection;
import org.apache.hc.core5.http.HttpException;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpRequest;
@@ -70,6 +71,7 @@ import org.apache.hc.core5.pool.ManagedConnPool;
import org.apache.hc.core5.pool.PoolEntry;
import org.apache.hc.core5.pool.PoolStats;
import org.apache.hc.core5.reactor.Command;
+import org.apache.hc.core5.reactor.IOEventHandler;
import org.apache.hc.core5.reactor.IOEventHandlerFactory;
import org.apache.hc.core5.reactor.IOReactorConfig;
import org.apache.hc.core5.reactor.IOSession;
@@ -446,9 +448,11 @@ public class HttpAsyncRequester extends AsyncRequester implements ConnPoolContro
final PoolEntry<HttpHost, IOSession> poolEntry = poolEntryRef.get();
if (poolEntry != null) {
final IOSession ioSession = poolEntry.getConnection();
- if (ioSession != null && ioSession.isOpen()) {
- return true;
+ if (ioSession == null || !ioSession.isOpen()) {
+ return false;
}
+ final IOEventHandler handler = ioSession.getHandler();
+ return (handler instanceof HttpConnection) && ((HttpConnection) handler).isOpen();
}
return false;
}