Add ability to set and get network timeout#1185
Add ability to set and get network timeout#1185madhav-db wants to merge 6 commits intodatabricks:mainfrom
Conversation
There was a problem hiding this comment.
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
DatabricksConnectionContextwith getter/setter methods - Implemented
setNetworkTimeout()andgetNetworkTimeout()inDatabricksConnectionwith input validation - Modified
DatabricksHttpClientto 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.
src/test/java/com/databricks/jdbc/api/impl/DatabricksConnectionTest.java
Show resolved
Hide resolved
src/main/java/com/databricks/jdbc/dbclient/impl/http/DatabricksHttpClient.java
Outdated
Show resolved
Hide resolved
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>
| if (connectionContext != null) { | ||
| int networkTimeout = connectionContext.getNetworkTimeout(); | ||
| if (networkTimeout > 0 && request instanceof HttpRequestBase) { | ||
| RequestConfig requestConfig = makeRequestConfig(connectionContext); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
Description
Add ability to set and get network timeout
Addresses: #1140
Testing
Additional Notes to the Reviewer