Just hit this bug.
Versions:
- google-http-client: 1.30.1
- google-http-client-apache-v2: 1.30.1
Here, the code is supposed to configure HttpClient with some curated values, but in reality, most of them are being ignored. I'll mark below which values are ignored:
// IGNORED
SocketConfig socketConfig = SocketConfig.custom()
.setRcvBufSize(8192) // IGNORED
.setSndBufSize(8192) // IGNORED
.build();
PoolingHttpClientConnectionManager connectionManager =
new PoolingHttpClientConnectionManager(-1, TimeUnit.MILLISECONDS);
connectionManager.setValidateAfterInactivity(-1);
return HttpClientBuilder.create()
.useSystemProperties()
// IGNORED
.setSSLSocketFactory(SSLConnectionSocketFactory.getSocketFactory())
.setDefaultSocketConfig(socketConfig) // IGNORED
.setMaxConnTotal(200) // IGNORED
.setMaxConnPerRoute(20) // IGNORED
.setRoutePlanner(new SystemDefaultRoutePlanner(ProxySelector.getDefault()))
.setConnectionManager(connectionManager)
.disableRedirectHandling()
.disableAutomaticRetries()
The reason is apparent from the Javadocs of the methods. For example, setDefaultSocketConfig says
* Please note this value can be overridden by the {@link #setConnectionManager(
* org.apache.http.conn.HttpClientConnectionManager)} method.
That is, calling setConnectionManager() makes the custom values set through the methods irrelevant. You can actually check this behavior in the build() method. For example,
if (connManagerCopy == null) {
...
// defaultSocketConfig is meaningful only when not calling setConnectionManager().
poolingmgr.setDefaultSocketConfig(defaultSocketConfig);
Just hit this bug.
Versions:
Here, the code is supposed to configure
HttpClientwith some curated values, but in reality, most of them are being ignored. I'll mark below which values are ignored:The reason is apparent from the Javadocs of the methods. For example,
setDefaultSocketConfigsaysThat is, calling
setConnectionManager()makes the custom values set through the methods irrelevant. You can actually check this behavior in thebuild()method. For example,