Skip to content

Commit a202fc4

Browse files
oschwaldclaude
andcommitted
STF-322: Document transport-failure retry in README and CHANGELOG
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 23248bb commit a202fc4

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
CHANGELOG
22
=========
33

4+
5.0.3 (unreleased)
5+
------------------
6+
7+
* Added `WebServiceClient.Builder.maxRetries(int)` to configure transport-failure
8+
retry behavior. Defaults to 1 (one retry on connection reset, broken pipe,
9+
or connect timeout). Set to 0 to disable. Request-phase timeouts and HTTP
10+
4xx/5xx responses are never retried.
11+
412
5.0.2 (2025-12-08)
513
------------------
614

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,41 @@ are not created for each request.
7272
See the [API documentation](https://maxmind.github.io/GeoIP2-java/) for
7373
more details.
7474

75+
### Connection pooling and transport retries ###
76+
77+
`WebServiceClient` is thread-safe and reuses a pooled `HttpClient` across
78+
requests. Idle connections in the pool can be silently closed by load
79+
balancers or other intermediaries. When the next request reuses one of these
80+
half-closed connections, the JDK reports the failure as a `Connection reset`
81+
(or `Broken pipe`) `IOException`.
82+
83+
To smooth over these intermittent transport failures, the SDK retries once by
84+
default. The retry covers:
85+
86+
* `SocketException` with message `Connection reset` or `Broken pipe`,
87+
* `ConnectException`,
88+
* `HttpConnectTimeoutException`.
89+
90+
Retries are **not** applied to request-phase timeouts (`HttpTimeoutException`)
91+
or to HTTP 4xx / 5xx responses. Web service requests are idempotent GETs, so
92+
retried requests are byte-identical to the original.
93+
94+
You can change the retry budget via the builder:
95+
96+
```java
97+
WebServiceClient client = new WebServiceClient.Builder(42, "license_key")
98+
.maxRetries(2) // up to two retries (three total attempts)
99+
.build();
100+
```
101+
102+
Set `.maxRetries(0)` to disable the retry entirely. Negative values throw
103+
`IllegalArgumentException`.
104+
105+
If you frequently see `Connection reset` errors, you can also reduce the
106+
JDK's keep-alive timeout via the system property
107+
`jdk.httpclient.keepalive.timeout` (in seconds) to evict pooled connections
108+
before any intermediary does so.
109+
75110
## Web Service Example ##
76111

77112
### Country Service ###

0 commit comments

Comments
 (0)