Skip to content

RetryPolicy exception aware timeout #37588

Open

Description

@knoobie

We would like to have a way to use different timeout values between tries depending the thrown exception.

For example: A race condition resulting in DataIntegrityViolationException could be retried after 100ms; while a ServiceUnavailableException might need a little bit more time to recover successfully.

Workaround:
Using setRetryPolicy with different timeouts depending on the exception available inside onRetryableExecution right before the timeout is evaluated.

Activity

  1. added
    in: coreIssues in core modules (aop, beans, core, context, expression)
    on Oct 25, 2026
  2. 03hjain commented on Oct 28, 2026

    @03hjain

    I can consider adding this if the group feels this is within the scope of the retry core.
    This could take the form of a BackOff which selects a delegate based on the last thrown exception as configured using RetryPolicy.Builder (for instance .backOffFor(DataIntegrityViolationException.class, Duration.ofMillis(100)) with the current backoff as fallback). The matching would happen according to exception type inheritance similar to how includes/excludes currently work. In case a different structure would be preferred like a Function<Throwable,Duration> callback, I am open to do that too.

  3. farheen-shaikh0509 commented on Oct 28, 2026

    @farheen-shaikh0509

    Hi! I would like to work on this issue. Could I take this up?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: coreIssues in core modules (aop, beans, core, context, expression)status: waiting-for-triageAn issue we've not yet triaged or decided on

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions