Skip to content

Commit

Permalink
[FIX] CommonHttpsClient Builder - set timeout correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
satviksr-db committed Oct 17, 2024
1 parent 6e71a0d commit 3755e57
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,8 @@ public CommonsHttpClient build() {

private static final Logger LOG = LoggerFactory.getLogger(CommonsHttpClient.class);
private final CloseableHttpClient hc;
private int timeout;

private CommonsHttpClient(Builder builder) {
HttpClientBuilder httpClientBuilder =
HttpClientBuilder.create().setDefaultRequestConfig(makeRequestConfig());
int timeoutSeconds = 300;
if (builder.databricksConfig != null
&& builder.databricksConfig.getHttpTimeoutSeconds() != null) {
Expand All @@ -117,7 +114,9 @@ private CommonsHttpClient(Builder builder) {
if (builder.timeoutSeconds != null) {
timeoutSeconds = builder.timeoutSeconds;
}
timeout = timeoutSeconds * 1000;
int timeout = timeoutSeconds * 1000;
HttpClientBuilder httpClientBuilder =
HttpClientBuilder.create().setDefaultRequestConfig(makeRequestConfig(timeout));
if (builder.proxyConfig != null) {
ProxyUtils.setupProxy(builder.proxyConfig, httpClientBuilder);
}
Expand All @@ -135,7 +134,7 @@ private CommonsHttpClient(Builder builder) {
hc = httpClientBuilder.build();
}

private RequestConfig makeRequestConfig() {
private RequestConfig makeRequestConfig(int timeout) {
return RequestConfig.custom()
.setConnectionRequestTimeout(timeout)
.setConnectTimeout(timeout)
Expand Down

0 comments on commit 3755e57

Please sign in to comment.