Skip to content

fix(httpclient): limit fixed retries to transient GET failures - #7180

Merged
Aias00 merged 2 commits into
apache:masterfrom
dengliming:fix-6575-limit-fixed-retries
Oct 1, 2026
Merged

Aias00 merged 2 commits into
apache:masterfrom
dengliming:fix-6575-limit-fixed-retries

Conversation

@dengliming

Copy link
Copy Markdown
Member

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:

  • RetryStrategyTest
  • Checkstyle

Aias00
Aias00 previously approved these changes Sep 24, 2026

@Aias00 Aias00 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 GET is the correct safety line. A GET is idempotent, so replaying it after a transient network failure is safe; POST/PUT are not.
  • isTransientFailure walks the cause chain, which matters a lot here: Reactor Netty typically wraps the underlying ConnectTimeoutException / PrematureCloseException inside a reactor or WebClient exception, so a shallow instanceof check would miss most real failures.
  • The chosen set (java/net timeouts, ConnectException, SocketTimeoutException, Reactor Netty's ConnectTimeoutException/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 generic RetryExhaustedException and 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 Aias00 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@Aias00
Aias00 merged commit a2e2640 into apache:master Oct 1, 2026
21 checks passed
@Aias00 Aias00 added this to the 2.7.2 milestone Nov 13, 2026
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.

[BUG] FixedRetryStrategy retries on ALL errors with no filter and no idempotency guard

2 participants