From 3755e578433ff8936c3b569a44badf8bb26ecf15 Mon Sep 17 00:00:00 2001 From: Satvik Ramaprasad Date: Thu, 17 Oct 2024 12:53:05 +0530 Subject: [PATCH] [FIX] CommonHttpsClient Builder - set timeout correctly --- .../databricks/sdk/core/commons/CommonsHttpClient.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/core/commons/CommonsHttpClient.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/core/commons/CommonsHttpClient.java index 0a4a81f3..0af1d223 100644 --- a/databricks-sdk-java/src/main/java/com/databricks/sdk/core/commons/CommonsHttpClient.java +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/core/commons/CommonsHttpClient.java @@ -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) { @@ -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); } @@ -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)