Skip to content

Commit

Permalink
Fix ApacheHttpTransport configuration (#717)
Browse files Browse the repository at this point in the history
* Switch back to deprecated setStaleConnectionCheck

* checkstyle fix for TODO
  • Loading branch information
chingor13 committed Jun 21, 2019
1 parent 509ab96 commit ca83de0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
Expand Up @@ -33,11 +33,15 @@ final class ApacheHttpRequest extends LowLevelHttpRequest {

private RequestConfig.Builder requestConfig;

@SuppressWarnings("deprecation")
ApacheHttpRequest(HttpClient httpClient, HttpRequestBase request) {
this.httpClient = httpClient;
this.request = request;
// disable redirects as google-http-client handles redirects
this.requestConfig = RequestConfig.custom().setRedirectsEnabled(false);
this.requestConfig = RequestConfig.custom()
.setRedirectsEnabled(false)
// TODO(chingor): configure in HttpClientBuilder when available
.setStaleConnectionCheckEnabled(false);
}

@Override
Expand Down
Expand Up @@ -130,22 +130,17 @@ public static HttpClient newDefaultHttpClient() {
.setSndBufSize(8192)
.build();

PoolingHttpClientConnectionManager connectionManager =
new PoolingHttpClientConnectionManager(-1, TimeUnit.MILLISECONDS);
// Disable the stale connection check (previously configured in the HttpConnectionParams
connectionManager.setValidateAfterInactivity(-1);

return HttpClientBuilder.create()
.useSystemProperties()
.setSSLSocketFactory(SSLConnectionSocketFactory.getSocketFactory())
.setDefaultSocketConfig(socketConfig)
.setMaxConnTotal(200)
.setMaxConnPerRoute(20)
.setRoutePlanner(new SystemDefaultRoutePlanner(ProxySelector.getDefault()))
.setConnectionManager(connectionManager)
.disableRedirectHandling()
.disableAutomaticRetries()
.build();
.useSystemProperties()
.setSSLSocketFactory(SSLConnectionSocketFactory.getSocketFactory())
.setDefaultSocketConfig(socketConfig)
.setMaxConnTotal(200)
.setMaxConnPerRoute(20)
.setConnectionTimeToLive(-1, TimeUnit.MILLISECONDS)
.setRoutePlanner(new SystemDefaultRoutePlanner(ProxySelector.getDefault()))
.disableRedirectHandling()
.disableAutomaticRetries()
.build();
}

@Override
Expand Down

0 comments on commit ca83de0

Please sign in to comment.