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 authored Jun 18, 2019
1 parent 4e77793 commit 88a6548
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -155,19 +155,14 @@ public static HttpClientBuilder newDefaultHttpClientBuilder() {
.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)
.setConnectionTimeToLive(-1, TimeUnit.MILLISECONDS)
.setRoutePlanner(new SystemDefaultRoutePlanner(ProxySelector.getDefault()))
.setConnectionManager(connectionManager)
.disableRedirectHandling()
.disableAutomaticRetries();
}
Expand Down

0 comments on commit 88a6548

Please sign in to comment.