Do not use system properties when building the HttpAsyncClient
This commit removes the usage of system properties for the HttpAsyncClient as this overrides some
defaults that we intentionally change. In order to set the default SSLContext to the system context
we set the SSLContext on the builder explicitly.
Closes
@@ -28,7 +28,9 @@ import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
import org.apache.http.nio.conn.SchemeIOSessionStrategy;
+import javax.net.ssl.SSLContext;
import java.security.AccessController;
+import java.security.NoSuchAlgorithmException;
import java.security.PrivilegedAction;
import java.util.Objects;
@@ -200,9 +202,11 @@ public final class RestClientBuilder {
requestConfigBuilder = requestConfigCallback.customizeRequestConfig(requestConfigBuilder);
}
+ try {
HttpAsyncClientBuilder httpClientBuilder = HttpAsyncClientBuilder.create().setDefaultRequestConfig(requestConfigBuilder.build())
//default settings for connection pooling may be too constraining
- .setMaxConnPerRoute(DEFAULT_MAX_CONN_PER_ROUTE).setMaxConnTotal(DEFAULT_MAX_CONN_TOTAL).useSystemProperties();
+ .setMaxConnPerRoute(DEFAULT_MAX_CONN_PER_ROUTE).setMaxConnTotal(DEFAULT_MAX_CONN_TOTAL)
+ .setSSLContext(SSLContext.getDefault());
if (httpClientConfigCallback != null) {
httpClientBuilder = httpClientConfigCallback.customizeHttpClient(httpClientBuilder);
}
@@ -214,6 +218,9 @@ public final class RestClientBuilder {
return finalBuilder.build();
}
});
+ } catch (NoSuchAlgorithmException e) {
+ throw new IllegalStateException("could not create the default ssl context", e);
+ }
}
/**
