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 2020/07/02 09:29:33 UTC
[httpcomponents-client] branch master updated: HTTPCLIENT-2094:
ConnectionManager validateAfterInactivity zero duration agreement
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 517e5c8 HTTPCLIENT-2094: ConnectionManager validateAfterInactivity zero duration agreement
517e5c8 is described below
commit 517e5c8d94cf7e5bb9863d21ea89d284c46b7d38
Author: Carter Kozak <ck...@apache.org>
AuthorDate: Wed Jul 1 13:47:01 2020 -0400
HTTPCLIENT-2094: ConnectionManager validateAfterInactivity zero duration agreement
Both connection managers agree on the meaning of a zero-duration
validateAfterInactivity value. Previously the documentation for
both suggested that zero resulted in no validation, however
the classic client would validate prior to each request and
the async client would never validate.
This commit standardizes behavior on the classic client, which
is consistent with hc4.x, allowing zero to force validation prior
to every request.
---
.../hc/client5/http/impl/io/PoolingHttpClientConnectionManager.java | 4 ++--
.../client5/http/impl/nio/PoolingAsyncClientConnectionManager.java | 6 +++---
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/PoolingHttpClientConnectionManager.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/PoolingHttpClientConnectionManager.java
index 7d29e2c..884957d 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/PoolingHttpClientConnectionManager.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/PoolingHttpClientConnectionManager.java
@@ -510,8 +510,8 @@ public class PoolingHttpClientConnectionManager
/**
* Defines period of inactivity after which persistent connections must
- * be re-validated prior to being {@link #lease(String, HttpRoute, Object)} leased} to the consumer.
- * Non-positive value passed to this method disables connection validation. This check helps
+ * be re-validated prior to being {@link #lease(String, HttpRoute, Object)} leased} to the consumer.
+ * Negative values passed to this method disable connection validation. This check helps
* detect connections that have become stale (half-closed) while kept inactive in the pool.
*
* @since 4.4
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 9582afb..121d189 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
@@ -245,7 +245,7 @@ public class PoolingAsyncClientConnectionManager implements AsyncClientConnectio
public void completed(final PoolEntry<HttpRoute, ManagedAsyncClientConnection> poolEntry) {
final ManagedAsyncClientConnection connection = poolEntry.getConnection();
final TimeValue timeValue = PoolingAsyncClientConnectionManager.this.validateAfterInactivity;
- if (TimeValue.isPositive(timeValue) && connection != null &&
+ if (TimeValue.isNonNegative(timeValue) && connection != null &&
poolEntry.getUpdated() + timeValue.toMilliseconds() <= System.currentTimeMillis()) {
final ProtocolVersion protocolVersion = connection.getProtocolVersion();
if (HttpVersion.HTTP_2_0.greaterEquals(protocolVersion)) {
@@ -478,8 +478,8 @@ public class PoolingAsyncClientConnectionManager implements AsyncClientConnectio
/**
* Defines period of inactivity after which persistent connections must
* be re-validated prior to being {@link #lease(String, HttpRoute, Object, Timeout,
- * FutureCallback)} leased} to the consumer. Non-positive value passed
- * to this method disables connection validation. This check helps detect connections
+ * FutureCallback)} leased} to the consumer. Negative values passed
+ * to this method disable connection validation. This check helps detect connections
* that have become stale (half-closed) while kept inactive in the pool.
*/
public void setValidateAfterInactivity(final TimeValue validateAfterInactivity) {