Skip to content

Add withRequestConfig to CommonsHttpClient.Builder#691

Open
renaudhartert-db wants to merge 3 commits intomainfrom
renaud-hartert/add-request-config-builder
Open

Add withRequestConfig to CommonsHttpClient.Builder#691
renaudhartert-db wants to merge 3 commits intomainfrom
renaud-hartert/add-request-config-builder

Conversation

@renaudhartert-db
Copy link
Contributor

@renaudhartert-db renaudhartert-db commented Mar 5, 2026

Summary

Add withRequestConfig(RequestConfig) to CommonsHttpClient.Builder so that users can independently configure connect, socket, and connection-request timeouts on the underlying Apache HttpClient.

Why

CommonsHttpClient.Builder.withTimeoutSeconds() sets all three Apache HttpClient timeouts (connect, socket, connection-request) to the same value. Users who need long socket timeouts for slow queries (e.g. 15 minutes) are forced to also set long connect timeouts, which means the application hangs for that entire duration if a host is unreachable.

Rather than mirroring Apache's RequestConfig API one field at a time on the builder, this PR exposes the RequestConfig directly. CommonsHttpClient already exposes other Apache types (SSLConnectionSocketFactory, PoolingHttpClientConnectionManager, HttpRequestRetryHandler), so this is consistent with the existing abstraction boundary. It also means any future RequestConfig options are available without further SDK changes.

What changed

Interface changes

  • CommonsHttpClient.Builder.withRequestConfig(RequestConfig) — accepts a custom Apache RequestConfig. When set, it takes precedence over withTimeoutSeconds() and any timeout from DatabricksConfig.
  • Updated Javadoc on withTimeoutSeconds() to reference withRequestConfig() as the fine-grained alternative.

Behavioral changes

None. Existing users who don't call withRequestConfig() get the same behavior as before.

Internal changes

  • Extracted timeout resolution logic from the constructor into a makeDefaultRequestConfig(DatabricksConfig, Integer) static method for clarity.

How is this tested?

  • New testCustomRequestConfig test in CommonsHttpClientTest builds a client with separate connect (10s), socket (900s), and connection-request (300s) timeouts and verifies it executes a request successfully.
  • All existing CommonsHttpClientTest tests pass.

Allow users to pass a custom Apache RequestConfig for fine-grained
timeout control (e.g. short connect timeout with long socket timeout).
The existing withTimeoutSeconds remains for the common case.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@renaudhartert-db renaudhartert-db force-pushed the renaud-hartert/add-request-config-builder branch from a2d6213 to ce927e5 Compare March 5, 2026 08:45
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link

github-actions bot commented Mar 5, 2026

If integration tests don't run automatically, an authorized user can run them manually by following the instructions below:

Trigger:
go/deco-tests-run/sdk-java

Inputs:

  • PR number: 691
  • Commit SHA: 3f4cb74d316120d55c477a840b3dec5577576c14

Checks will be approved automatically on success.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant