Bug fix: Incorrect connection validity check in the async connection manager can cause an IllegalStateException and lead to a connection leak. Treat closed connections as valid due to the connection open check being inherently racy

This commit is contained in:
Oleg Kalnichevski 2021-12-16 20:40:04 +01:00
parent 66158af338
commit 19571aa207
1 changed files with 3 additions and 3 deletions

View File

@ -87,7 +87,6 @@ import org.apache.hc.core5.reactor.ConnectionInitiator;
import org.apache.hc.core5.reactor.ProtocolIOSession;
import org.apache.hc.core5.reactor.ssl.TlsDetails;
import org.apache.hc.core5.util.Args;
import org.apache.hc.core5.util.Asserts;
import org.apache.hc.core5.util.Deadline;
import org.apache.hc.core5.util.Identifiable;
import org.apache.hc.core5.util.TimeValue;
@ -668,8 +667,9 @@ public class PoolingAsyncClientConnectionManager implements AsyncClientConnectio
PoolEntry<HttpRoute, ManagedAsyncClientConnection> getValidatedPoolEntry() {
final PoolEntry<HttpRoute, ManagedAsyncClientConnection> poolEntry = getPoolEntry();
final ManagedAsyncClientConnection connection = poolEntry.getConnection();
Asserts.check(connection != null && connection.isOpen(), "Endpoint is not connected");
if (poolEntry.getConnection() == null) {
throw new ConnectionShutdownException();
}
return poolEntry;
}