Skip to content

fix(token-client): retry on network errors across plain + Spring clients (4.3.1) - #2068

Merged
NiklasHerrmann21 merged 5 commits into
mainfrom
fix/token-client-retry-network-errors
Nov 6, 2026
Merged

NiklasHerrmann21 merged 5 commits into
mainfrom
fix/token-client-retry-network-errors

Conversation

@NiklasHerrmann21

@NiklasHerrmann21 NiklasHerrmann21 commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

What

Make the token-client retry feature act on network errors, not only on configured HTTP status codes — consistently across the plain client and both Spring variants.

Reported via DINC (Jonas): the retry docs promise retries on "network issues, such as timeouts or connection errors", but the retry only fired on status codes. A timeout / connection reset / TLS error was thrown before any status code existed and was rethrown with no retry — surfacing as Error retrieving token keys: null during short XSUAA/IAS blips, even with retryEnabled=true and maxRetryAttempts set.

A follow-up review showed the same gap existed in every retrying HTTP caller, including the Spring variants, so this PR covers all of them.

Changes

token-client (plain, retry on IOException):

  • DefaultOAuth2TokenService
  • DefaultOAuth2TokenKeyService
  • DefaultOidcConfigurationService

token-client-spring + token-client-spring-3 (retry on ResourceAccessException):

  • XsuaaOAuth2TokenService

  • SpringOAuth2TokenKeyService

  • SpringOidcConfigurationService

  • All retries bounded by the existing maxRetryAttempts / retryDelayTime.

  • OAuth2ServiceException (an already-decided HTTP outcome) is still never retried.

  • Spring variants additionally route retryable HttpStatusCodeException through the same retry handling, so the configured retryStatusCodes now actually take effect even though RestTemplate surfaces non-2xx responses as exceptions.

Tests

Added network-error retry tests (then-success, retry-until-max-then-throw) to all six services across the three modules. Full suites green:

  • token-client: DefaultOAuth2TokenKeyServiceTest 16, DefaultOAuth2TokenServiceTest 20, DefaultOidcConfigurationServiceTest 15
  • token-client-spring & token-client-spring-3: SpringOAuth2TokenKeyServiceTest 16, XsuaaOAuth2TokenServiceTest 18, SpringOidcConfigurationServiceTest 14 (each)

Note

A larger retry rework (resilience4j) is planned separately and would supersede this hand-rolled loop; this is the targeted fix so the behavior matches the docs now.

Prepares release 4.3.1 (version bump across all modules + CHANGELOG).

DefaultOAuth2TokenService and DefaultOAuth2TokenKeyService retried only on
configured HTTP status codes. An IOException from the HTTP client (connection
reset, read timeout, TLS handshake error) was rethrown immediately, so
transient network failures were never retried even with retry enabled
(surfaced as 'Error retrieving token keys: null' during short XSUAA/IAS blips).

Retry on IOException as well, bounded by the existing maxRetryAttempts and
retryDelayTime. OAuth2ServiceException (an already-decided HTTP outcome) is
still not retried. This matches the documented retry behavior for network
errors.

Prepare release 4.3.1 (version bump + changelog).
…twork errors

Extend the network-error retry fix to every retrying HTTP caller so the
behavior is consistent across the plain and Spring clients:

- DefaultOidcConfigurationService (token-client): retry on IOException,
  like DefaultOAuth2TokenService/DefaultOAuth2TokenKeyService.
- XsuaaOAuth2TokenService, SpringOAuth2TokenKeyService,
  SpringOidcConfigurationService (token-client-spring + token-client-spring-3):
  retry on ResourceAccessException (network errors), and route retryable
  HttpStatusCodeException through the same retry handling so configured
  retryStatusCodes take effect even though RestTemplate surfaces non-2xx as
  exceptions.

All bounded by the existing maxRetryAttempts/retryDelayTime;
OAuth2ServiceException is never retried. Adds network-error retry tests to
all six services (token-client + both Spring modules). Updates CHANGELOG 4.3.1.
@NiklasHerrmann21 NiklasHerrmann21 changed the title fix(token-client): retry token and JWKS requests on network errors (4.3.1) fix(token-client): retry on network errors across plain + Spring clients (4.3.1) Nov 6, 2026
kuntzed
kuntzed previously approved these changes Nov 6, 2026
…ve information into log files'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: NiklasHerrmann21 <niklas.herrmann01@sap.com>
…ve information into log files'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: NiklasHerrmann21 <niklas.herrmann01@sap.com>
@NiklasHerrmann21
NiklasHerrmann21 merged commit e2bf023 into main Nov 6, 2026
4 checks passed
@NiklasHerrmann21
NiklasHerrmann21 deleted the fix/token-client-retry-network-errors branch November 6, 2026 10:40
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.

3 participants