Lines 253-260
Link Here
|
253 |
|
253 |
|
254 |
private volatile HttpUriRequest currentRequest; // Accessed from multiple threads |
254 |
private volatile HttpUriRequest currentRequest; // Accessed from multiple threads |
255 |
|
255 |
|
256 |
private volatile boolean resetSSLContext; |
256 |
private static final ThreadLocal<Boolean> closeConnections = |
|
|
257 |
new ThreadLocal<Boolean>(){ |
258 |
@Override |
259 |
protected Boolean initialValue() { |
260 |
return new Boolean(false); |
261 |
} |
262 |
}; |
257 |
|
263 |
|
|
|
264 |
private static final ThreadLocal<Boolean> resetHTTPClient = |
265 |
new ThreadLocal<Boolean>(){ |
266 |
@Override |
267 |
protected Boolean initialValue() { |
268 |
return new Boolean(false); |
269 |
} |
270 |
}; |
271 |
|
258 |
protected HTTPHC4Impl(HTTPSamplerBase testElement) { |
272 |
protected HTTPHC4Impl(HTTPSamplerBase testElement) { |
259 |
super(testElement); |
273 |
super(testElement); |
260 |
} |
274 |
} |
Lines 697-710
Link Here
|
697 |
|
711 |
|
698 |
HttpClient httpClient = mapHttpClientPerHttpClientKey.get(key); |
712 |
HttpClient httpClient = mapHttpClientPerHttpClientKey.get(key); |
699 |
|
713 |
|
700 |
if (httpClient != null && resetSSLContext && HTTPConstants.PROTOCOL_HTTPS.equalsIgnoreCase(url.getProtocol())) { |
714 |
if (closeConnections.get()) { |
701 |
((AbstractHttpClient) httpClient).clearRequestInterceptors(); |
715 |
for (HttpClient cl : mapHttpClientPerHttpClientKey.values()) { |
702 |
((AbstractHttpClient) httpClient).clearResponseInterceptors(); |
716 |
cl.getConnectionManager().closeIdleConnections(1L, TimeUnit.MICROSECONDS); |
703 |
httpClient.getConnectionManager().closeIdleConnections(1L, TimeUnit.MICROSECONDS); |
717 |
} |
704 |
httpClient = null; |
718 |
closeConnections.set(false); |
|
|
719 |
} |
720 |
if (resetHTTPClient.get()) { |
721 |
if (httpClient != null) { |
722 |
((AbstractHttpClient) httpClient).clearRequestInterceptors(); |
723 |
((AbstractHttpClient) httpClient).clearResponseInterceptors(); |
724 |
httpClient = null; |
725 |
} |
726 |
resetHTTPClient.set(false); |
727 |
} |
728 |
if (resetSSLContext.get() && HTTPConstants.PROTOCOL_HTTPS.equalsIgnoreCase(url.getProtocol())) { |
705 |
JsseSSLManager sslMgr = (JsseSSLManager) SSLManager.getInstance(); |
729 |
JsseSSLManager sslMgr = (JsseSSLManager) SSLManager.getInstance(); |
706 |
sslMgr.resetContext(); |
730 |
sslMgr.resetContext(); |
707 |
resetSSLContext = false; |
731 |
resetSSLContext.set(false); |
708 |
} |
732 |
} |
709 |
|
733 |
|
710 |
if (httpClient == null){ // One-time init for this client |
734 |
if (httpClient == null){ // One-time init for this client |
Lines 1395-1402
Link Here
|
1395 |
|
1419 |
|
1396 |
@Override |
1420 |
@Override |
1397 |
protected void notifyFirstSampleAfterLoopRestart() { |
1421 |
protected void notifyFirstSampleAfterLoopRestart() { |
|
|
1422 |
// see https://bz.apache.org/bugzilla/show_bug.cgi?id=51380 |
1398 |
log.debug("notifyFirstSampleAfterLoopRestart"); |
1423 |
log.debug("notifyFirstSampleAfterLoopRestart"); |
1399 |
resetSSLContext = !USE_CACHED_SSL_CONTEXT; |
1424 |
closeConnections.set(!REUSE_HTTP_CONNECTIONS); |
|
|
1425 |
resetHTTPClient.set(!REUSE_HTTP_CLIENT); |
1426 |
resetSSLContext.set(!USE_CACHED_SSL_CONTEXT); |
1400 |
} |
1427 |
} |
1401 |
|
1428 |
|
1402 |
@Override |
1429 |
@Override |