Skip to content

Commit f4e396f

Browse files
yhzdysok2c
authored andcommitted
Bug fix: Correct the issue with connection state detection in DefaultManagedAsyncClientConnection#isOpen().
1 parent ca5e14e commit f4e396f

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/DefaultManagedAsyncClientConnection.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,20 @@ public void close() throws IOException {
9898

9999
@Override
100100
public boolean isOpen() {
101-
return ioSession.isOpen();
101+
final IOSession ioSession = this.ioSession;
102+
if (ioSession.isOpen()) {
103+
final IOEventHandler handler = ioSession.getHandler();
104+
if (handler instanceof HttpConnection) {
105+
final HttpConnection conn = (HttpConnection) handler;
106+
final ProtocolVersion protocolVersion = conn.getProtocolVersion();
107+
if (protocolVersion != null && protocolVersion.greaterEquals(HttpVersion.HTTP_2)) {
108+
return conn.isOpen();
109+
}
110+
}
111+
return true;
112+
} else {
113+
return false;
114+
}
102115
}
103116

104117
@Override

0 commit comments

Comments
 (0)