Commit 848a952
Add withRequestConfig to CommonsHttpClient.Builder (#691)
## 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.
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent a6044f4 commit 848a952
File tree
3 files changed
+52
-12
lines changed- databricks-sdk-java/src
- main/java/com/databricks/sdk/core/commons
- test/java/com/databricks/sdk/core/commons
3 files changed
+52
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
Lines changed: 30 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
| |||
65 | 66 | | |
66 | 67 | | |
67 | 68 | | |
68 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
69 | 72 | | |
70 | 73 | | |
71 | 74 | | |
72 | 75 | | |
73 | 76 | | |
74 | 77 | | |
75 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
76 | 90 | | |
77 | 91 | | |
78 | 92 | | |
| |||
121 | 135 | | |
122 | 136 | | |
123 | 137 | | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
133 | 142 | | |
134 | | - | |
| 143 | + | |
135 | 144 | | |
136 | 145 | | |
137 | 146 | | |
| |||
156 | 165 | | |
157 | 166 | | |
158 | 167 | | |
159 | | - | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
160 | 178 | | |
161 | 179 | | |
162 | 180 | | |
| |||
Lines changed: 21 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| 14 | + | |
| 15 | + | |
13 | 16 | | |
14 | 17 | | |
15 | 18 | | |
| |||
88 | 91 | | |
89 | 92 | | |
90 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
91 | 112 | | |
92 | 113 | | |
93 | 114 | | |
| |||
0 commit comments