HTTPCORE-672: cleanup of H2 connection validation code
This commit is contained in:
parent
f597588198
commit
935abae04e
|
@ -243,37 +243,38 @@ public class PoolingAsyncClientConnectionManager implements AsyncClientConnectio
|
||||||
@Override
|
@Override
|
||||||
public void completed(final PoolEntry<HttpRoute, ManagedAsyncClientConnection> poolEntry) {
|
public void completed(final PoolEntry<HttpRoute, ManagedAsyncClientConnection> poolEntry) {
|
||||||
final ManagedAsyncClientConnection connection = poolEntry.getConnection();
|
final ManagedAsyncClientConnection connection = poolEntry.getConnection();
|
||||||
final TimeValue timeValue = PoolingAsyncClientConnectionManager.this.validateAfterInactivity;
|
if (connection != null) {
|
||||||
if (TimeValue.isNonNegative(timeValue) && connection != null &&
|
if (connection.isOpen()) {
|
||||||
poolEntry.getUpdated() + timeValue.toMilliseconds() <= System.currentTimeMillis()) {
|
final ProtocolVersion protocolVersion = connection.getProtocolVersion();
|
||||||
final ProtocolVersion protocolVersion = connection.getProtocolVersion();
|
if (protocolVersion != null && protocolVersion.greaterEquals(HttpVersion.HTTP_2_0)) {
|
||||||
if (protocolVersion != null && protocolVersion.greaterEquals(HttpVersion.HTTP_2_0)) {
|
final TimeValue timeValue = PoolingAsyncClientConnectionManager.this.validateAfterInactivity;
|
||||||
connection.submitCommand(new PingCommand(new BasicPingHandler(new Callback<Boolean>() {
|
if (TimeValue.isNonNegative(timeValue) &&
|
||||||
|
poolEntry.getUpdated() + timeValue.toMilliseconds() <= System.currentTimeMillis()) {
|
||||||
|
connection.submitCommand(new PingCommand(new BasicPingHandler(new Callback<Boolean>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final Boolean result) {
|
public void execute(final Boolean result) {
|
||||||
if (result == null || !result) {
|
if (result == null || !result) {
|
||||||
if (LOG.isDebugEnabled()) {
|
if (LOG.isDebugEnabled()) {
|
||||||
LOG.debug("{} connection {} is stale", id, ConnPoolSupport.getId(connection));
|
LOG.debug("{} connection {} is stale", id, ConnPoolSupport.getId(connection));
|
||||||
|
}
|
||||||
|
poolEntry.discardConnection(CloseMode.IMMEDIATE);
|
||||||
|
}
|
||||||
|
leaseCompleted(poolEntry);
|
||||||
}
|
}
|
||||||
poolEntry.discardConnection(CloseMode.IMMEDIATE);
|
|
||||||
}
|
|
||||||
leaseCompleted(poolEntry);
|
|
||||||
}
|
|
||||||
|
|
||||||
})), Command.Priority.IMMEDIATE);
|
})), Command.Priority.IMMEDIATE);
|
||||||
} else {
|
return;
|
||||||
if (!connection.isOpen()) {
|
|
||||||
if (LOG.isDebugEnabled()) {
|
|
||||||
LOG.debug("{} connection {} is closed", id, ConnPoolSupport.getId(connection));
|
|
||||||
}
|
}
|
||||||
poolEntry.discardConnection(CloseMode.IMMEDIATE);
|
|
||||||
}
|
}
|
||||||
leaseCompleted(poolEntry);
|
} else {
|
||||||
|
if (LOG.isDebugEnabled()) {
|
||||||
|
LOG.debug("{} connection {} is closed", id, ConnPoolSupport.getId(connection));
|
||||||
|
}
|
||||||
|
poolEntry.discardConnection(CloseMode.IMMEDIATE);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
leaseCompleted(poolEntry);
|
|
||||||
}
|
}
|
||||||
|
leaseCompleted(poolEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue