Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] CommonHttpsClient Builder - set timeout correctly #362

Merged
merged 3 commits into from
Oct 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading