Skip to content

Commit

Permalink
Merge pull request #4099 from jamezp/RESTEASY-3470-6.2
Browse files Browse the repository at this point in the history
[RESTEASY-3470] Ensure idle connections are evicted.
  • Loading branch information
jamezp committed Mar 21, 2024
2 parents 580508d + 74a30f3 commit d8efb86
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,15 @@ protected ClientHttpEngine createEngine(final HttpClientConnectionManager cm, fi
final SSLContext theContext) {
final HttpClient httpClient;
rcBuilder.setProxy(defaultProxy);
// This is somewhat an arbitrary number of seconds to run the eviction thread at. However, this is the default
// in WildFly so we will use it. We are not exposing this as a property as other clients may not require a
// a setting like this.
final long maxIdleTime = 60L;
if (System.getSecurityManager() == null) {
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create()
.setConnectionManager(cm)
.evictExpiredConnections()
.evictIdleConnections(maxIdleTime, TimeUnit.SECONDS)
.setDefaultRequestConfig(rcBuilder.build())
.disableContentCompression();
if (!that.isCookieManagementEnabled()) {
Expand All @@ -217,6 +223,8 @@ protected ClientHttpEngine createEngine(final HttpClientConnectionManager cm, fi
public HttpClient run() {
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create()
.setConnectionManager(cm)
.evictExpiredConnections()
.evictIdleConnections(maxIdleTime, TimeUnit.SECONDS)
.setDefaultRequestConfig(rcBuilder.build())
.disableContentCompression();
if (!that.isCookieManagementEnabled()) {
Expand Down

0 comments on commit d8efb86

Please sign in to comment.