jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject [jmeter] branch master updated: Construct an InheritableThreadLocal instead of a simple ThreadLocal
Date Sat, 09 May 2020 09:27:49 GMT
This is an automated email from the ASF dual-hosted git repository.

fschumacher pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git


The following commit(s) were added to refs/heads/master by this push:
     new 20bc145  Construct an InheritableThreadLocal instead of a simple ThreadLocal
20bc145 is described below

commit 20bc14513b238f79d6190971e4617ac9c5f88c49
Author: Felix Schumacher <felix.schumacher@internetallee.de>
AuthorDate: Sat May 9 11:25:22 2020 +0200

    Construct an InheritableThreadLocal instead of a simple ThreadLocal
    
    The method withInitial is a static method on ThreadLocal and will create
    a normal ThreadLocal instance. We want an InheritableThreadLocal instance
    and have to use the old fashioned way of using an anonymous subclass
    for creation of initial values.
---
 .../org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java     | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
b/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
index b24cb66..ee79e64 100644
--- a/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
+++ b/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
@@ -438,9 +438,12 @@ public class HTTPHC4Impl extends HTTPHCAbstractImpl {
     /**
      * 1 HttpClient instance per combination of (HttpClient,HttpClientKey)
      */
-    private static final ThreadLocal<Map<HttpClientKey, MutableTriple<CloseableHttpClient,
AuthState, PoolingHttpClientConnectionManager>>>
-        HTTPCLIENTS_CACHE_PER_THREAD_AND_HTTPCLIENTKEY =
-            InheritableThreadLocal.withInitial(() -> new HashMap<>(5));
+    private static final ThreadLocal<Map<HttpClientKey, MutableTriple<CloseableHttpClient,
AuthState, PoolingHttpClientConnectionManager>>>HTTPCLIENTS_CACHE_PER_THREAD_AND_HTTPCLIENTKEY
= new InheritableThreadLocal<Map<HttpClientKey, MutableTriple<CloseableHttpClient,
AuthState, PoolingHttpClientConnectionManager>>>() {
+        @Override
+        protected Map<HttpClientKey, MutableTriple<CloseableHttpClient, AuthState,
PoolingHttpClientConnectionManager>> initialValue() {
+            return new HashMap<>(5);
+        }
+    };
 
     /**
      * CONNECTION_SOCKET_FACTORY changes if we want to simulate Slow connection


Mime
View raw message