Skip to content

Conversation

@madhav-db
Copy link
Collaborator

Description

Add ability to set and get network timeout
Addresses: #1140

Testing

Additional Notes to the Reviewer

Copilot AI review requested due to automatic review settings January 20, 2026 10:46
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request implements the setNetworkTimeout() and getNetworkTimeout() methods on the JDBC Connection interface, addressing issue #1140. The implementation allows users to configure network I/O timeout for database operations.

Changes:

  • Added network timeout storage in DatabricksConnectionContext with getter/setter methods
  • Implemented setNetworkTimeout() and getNetworkTimeout() in DatabricksConnection with input validation
  • Modified DatabricksHttpClient to use network timeout when set, falling back to socket timeout otherwise

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/main/java/com/databricks/jdbc/api/impl/DatabricksConnection.java Implements setNetworkTimeout/getNetworkTimeout methods with validation for negative values
src/main/java/com/databricks/jdbc/api/internal/IDatabricksConnectionContext.java Adds interface methods for getting and setting network timeout
src/main/java/com/databricks/jdbc/api/impl/DatabricksConnectionContext.java Stores network timeout as volatile int field with getter/setter implementation
src/main/java/com/databricks/jdbc/dbclient/impl/http/DatabricksHttpClient.java Updates RequestConfig creation to prefer network timeout over socket timeout
src/test/java/com/databricks/jdbc/api/impl/DatabricksConnectionTest.java Adds basic tests for network timeout getter/setter and negative value validation
NEXT_CHANGELOG.md Documents the new feature in changelog
.metals/metals.lock.db IDE-generated lock file (should not be committed)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

madhav-db and others added 3 commits January 20, 2026 10:51
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Address Copilot feedback: Network timeout now takes effect immediately
by applying RequestConfig per-request instead of only during HTTP client
initialization. This allows setNetworkTimeout() to work correctly without
requiring HTTP client recreation.

Changes:
- Apply RequestConfig dynamically in execute() when network timeout is set
- Import HttpRequestBase to enable per-request config override
- Update CHANGELOG to clarify dynamic timeout application

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@madhav-db madhav-db requested a review from gopalldb January 21, 2026 08:53
if (connectionContext != null) {
int networkTimeout = connectionContext.getNetworkTimeout();
if (networkTimeout > 0 && request instanceof HttpRequestBase) {
RequestConfig requestConfig = makeRequestConfig(connectionContext);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if there is already a request config? You would be overwriting that.

if (connectionContext != null) {
int networkTimeout = connectionContext.getNetworkTimeout();
if (networkTimeout > 0 && request instanceof HttpRequestBase) {
RequestConfig requestConfig = makeRequestConfig(connectionContext);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will only affect Cloud fetch and Thrift server client. This won't affect SDK Http client.

int networkTimeout = connectionContext.getNetworkTimeout();
if (networkTimeout > 0 && request instanceof HttpRequestBase) {
RequestConfig requestConfig = makeRequestConfig(connectionContext);
((HttpRequestBase) request).setConfig(requestConfig);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the JDBC spec, the network timeout seems to consider across all retried requests, whereas you are setting it for each request. I will increase timeout for overall user request end to end

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.

2 participants