Repository navigation
fix(httpclient): limit fixed retries to transient GET failures - #7180
Conversation
Aias00
left a comment
There was a problem hiding this comment.
Solid hardening — the previous filter (!(t instanceof DataBufferLimitException)) retried everything else, meaning a 500 from the upstream, a serialization error, or any business exception triggered up to N retries of a request that had already been fully processed. That is both wasted work and, for non-idempotent methods, potentially harmful.
Points I like:
- Restricting retries to
GETis the correct safety line. A GET is idempotent, so replaying it after a transient network failure is safe; POST/PUT are not. isTransientFailurewalks the cause chain, which matters a lot here: Reactor Netty typically wraps the underlyingConnectTimeoutException/PrematureCloseExceptioninside a reactor or WebClient exception, so a shallowinstanceofcheck would miss most real failures.- The chosen set (java/net timeouts,
ConnectException,SocketTimeoutException, Reactor Netty'sConnectTimeoutException/ReadTimeoutException/PrematureCloseException) is exactly the "the request probably never reached the server" family. onRetryExhaustedThrow((spec, sig) -> sig.failure())is an important detail: without it, callers get a genericRetryExhaustedExceptionand lose the original cause. Now the real error propagates.- Ordering is correct —
.retryWhen(...)is applied before.timeout(...), so the overall deadline governs the whole retry sequence rather than being retried itself.
The three tests cover precisely the decision matrix: GET + transient → retried (3 attempts), GET + permanent → 1 attempt, POST + transient → 1 attempt.
Non-blocking: HEAD is also idempotent; if you want symmetry with the safety argument, HttpMethod.GET.equals(...) || HttpMethod.HEAD.equals(...) would be a one-line extension.
Aias00
left a comment
There was a problem hiding this comment.
Reviewed the current head. Fixed retries are correctly limited to transient GET failures, with negative-path coverage for permanent errors and POST requests. No blocking issues found.
Fixes #6575.
Limits the fixed-delay retry strategy to GET requests that fail with explicit transient network or timeout exceptions. Permanent failures and non-GET requests are returned without retrying, preventing retry amplification and duplicate writes.
Tests: