You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2021/04/02 20:10:17 UTC
[httpcomponents-client] branch master updated: HTTPCORE-672:
cleanup of H2 connection validation code
This is an automated email from the ASF dual-hosted git repository.
olegk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git
The following commit(s) were added to refs/heads/master by this push:
new 935abae HTTPCORE-672: cleanup of H2 connection validation code
935abae is described below
commit 935abae04e76f5de3971ad60b80dfc5d9985d8ad
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Fri Apr 2 22:00:52 2021 +0200
HTTPCORE-672: cleanup of H2 connection validation code
---
.../nio/PoolingAsyncClientConnectionManager.java | 51 +++++++++++-----------
1 file changed, 26 insertions(+), 25 deletions(-)
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java
index a5d0aab..584951a 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java
@@ -243,37 +243,38 @@ public class PoolingAsyncClientConnectionManager implements AsyncClientConnectio
@Override
public void completed(final PoolEntry<HttpRoute, ManagedAsyncClientConnection> poolEntry) {
final ManagedAsyncClientConnection connection = poolEntry.getConnection();
- final TimeValue timeValue = PoolingAsyncClientConnectionManager.this.validateAfterInactivity;
- if (TimeValue.isNonNegative(timeValue) && connection != null &&
- poolEntry.getUpdated() + timeValue.toMilliseconds() <= System.currentTimeMillis()) {
- final ProtocolVersion protocolVersion = connection.getProtocolVersion();
- if (protocolVersion != null && protocolVersion.greaterEquals(HttpVersion.HTTP_2_0)) {
- connection.submitCommand(new PingCommand(new BasicPingHandler(new Callback<Boolean>() {
-
- @Override
- public void execute(final Boolean result) {
- if (result == null || !result) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("{} connection {} is stale", id, ConnPoolSupport.getId(connection));
+ if (connection != null) {
+ if (connection.isOpen()) {
+ final ProtocolVersion protocolVersion = connection.getProtocolVersion();
+ if (protocolVersion != null && protocolVersion.greaterEquals(HttpVersion.HTTP_2_0)) {
+ final TimeValue timeValue = PoolingAsyncClientConnectionManager.this.validateAfterInactivity;
+ if (TimeValue.isNonNegative(timeValue) &&
+ poolEntry.getUpdated() + timeValue.toMilliseconds() <= System.currentTimeMillis()) {
+ connection.submitCommand(new PingCommand(new BasicPingHandler(new Callback<Boolean>() {
+
+ @Override
+ public void execute(final Boolean result) {
+ if (result == null || !result) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("{} connection {} is stale", id, ConnPoolSupport.getId(connection));
+ }
+ poolEntry.discardConnection(CloseMode.IMMEDIATE);
+ }
+ leaseCompleted(poolEntry);
}
- poolEntry.discardConnection(CloseMode.IMMEDIATE);
- }
- leaseCompleted(poolEntry);
- }
- })), Command.Priority.IMMEDIATE);
- } else {
- if (!connection.isOpen()) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("{} connection {} is closed", id, ConnPoolSupport.getId(connection));
+ })), Command.Priority.IMMEDIATE);
+ return;
}
- 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