diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/DefaultManagedAsyncClientConnection.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/DefaultManagedAsyncClientConnection.java index e7142092fe..e50cec04e6 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/DefaultManagedAsyncClientConnection.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/DefaultManagedAsyncClientConnection.java @@ -98,7 +98,20 @@ public void close() throws IOException { @Override public boolean isOpen() { - return ioSession.isOpen(); + final IOSession ioSession = this.ioSession; + if (ioSession.isOpen()) { + final IOEventHandler handler = ioSession.getHandler(); + if (handler instanceof HttpConnection) { + final HttpConnection conn = (HttpConnection) handler; + final ProtocolVersion protocolVersion = conn.getProtocolVersion(); + if (protocolVersion != null && protocolVersion.greaterEquals(HttpVersion.HTTP_2)) { + return conn.isOpen(); + } + } + return true; + } else { + return false; + } } @Override