mirror of
https://github.com/apache/httpcomponents-client.git
synced 2025-02-28 05:39:07 +00:00
Fixed NPE PoolingAsyncClientConnectionManager
PoolingAsyncClientConnectionManager.validateAfterInactivity causes an NPE when PoolEntries are initially created with no Connection. Added logic to avoid checking the connection on every pool checkout similar to the blocking pool. Added an connection.isOpen check to http1.x connections leased from the pool, although I'm unsure if it's at all effective. Closes PR #82
This commit is contained in:
parent
a10967a427
commit
272ea1fa83
@ -164,8 +164,9 @@ void leaseCompleted(final PoolEntry<HttpRoute, ManagedAsyncClientConnection> poo
|
||||
|
||||
@Override
|
||||
public void completed(final PoolEntry<HttpRoute, ManagedAsyncClientConnection> poolEntry) {
|
||||
if (TimeValue.isPositive(validateAfterInactivity)) {
|
||||
final ManagedAsyncClientConnection connection = poolEntry.getConnection();
|
||||
final ManagedAsyncClientConnection connection = poolEntry.getConnection();
|
||||
if (TimeValue.isPositive(validateAfterInactivity) && connection != null &&
|
||||
poolEntry.getUpdated() + validateAfterInactivity.toMillis() <= System.currentTimeMillis()) {
|
||||
final ProtocolVersion protocolVersion = connection.getProtocolVersion();
|
||||
if (HttpVersion.HTTP_2_0.greaterEquals(protocolVersion)) {
|
||||
connection.submitPriorityCommand(new PingCommand(new BasicPingHandler(new Callback<Boolean>() {
|
||||
@ -183,6 +184,12 @@ public void execute(final Boolean result) {
|
||||
|
||||
})));
|
||||
} else {
|
||||
if (!connection.isOpen()) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Connection " + ConnPoolSupport.getId(connection) + " is closed");
|
||||
}
|
||||
poolEntry.discardConnection(ShutdownType.IMMEDIATE);
|
||||
}
|
||||
leaseCompleted(poolEntry);
|
||||
}
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user