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/08/11 10:12:33 UTC
[httpcomponents-client] branch master updated: HTTPCLIENT-2107:
Threadsafe PoolingHttpClientConnectionManager field volatile access
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 4f47c4a HTTPCLIENT-2107: Threadsafe PoolingHttpClientConnectionManager field volatile access
4f47c4a is described below
commit 4f47c4abc095f469584e05819420a3b2d506186e
Author: Carter Kozak <ck...@apache.org>
AuthorDate: Mon Aug 10 11:34:24 2020 -0400
HTTPCLIENT-2107: Threadsafe PoolingHttpClientConnectionManager field volatile access
---
.../client5/http/impl/io/PoolingHttpClientConnectionManager.java | 8 +++++---
1 file changed, 5 insertions(+), 3 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 e236ee4..d4799e6 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
@@ -286,10 +286,11 @@ public class PoolingHttpClientConnectionManager
LOG.debug("{}: endpoint leased {}", id, ConnPoolSupport.formatStats(route, state, pool));
}
try {
- if (TimeValue.isNonNegative(validateAfterInactivity)) {
+ final TimeValue validateAfterInactivitySnapshot = validateAfterInactivity;
+ if (TimeValue.isNonNegative(validateAfterInactivitySnapshot)) {
final ManagedHttpClientConnection conn = poolEntry.getConnection();
if (conn != null
- && poolEntry.getUpdated() + validateAfterInactivity.toMilliseconds() <= System.currentTimeMillis()) {
+ && poolEntry.getUpdated() + validateAfterInactivitySnapshot.toMilliseconds() <= System.currentTimeMillis()) {
boolean stale;
try {
stale = conn.isStale();
@@ -407,12 +408,13 @@ public class PoolingHttpClientConnectionManager
LOG.debug("{}: connecting endpoint to {} ({})", ConnPoolSupport.getId(endpoint), host, connectTimeout);
}
final ManagedHttpClientConnection conn = poolEntry.getConnection();
+ final SocketConfig defaultSocketConfigSnapshot = defaultSocketConfig;
this.connectionOperator.connect(
conn,
host,
route.getLocalSocketAddress(),
connectTimeout,
- defaultSocketConfig != null ? this.defaultSocketConfig : SocketConfig.DEFAULT,
+ defaultSocketConfigSnapshot != null ? defaultSocketConfigSnapshot : SocketConfig.DEFAULT,
context);
if (LOG.isDebugEnabled()) {
LOG.debug("{}: connected {}", ConnPoolSupport.getId(endpoint), ConnPoolSupport.getId(conn));