Skip to content

@Retryable annotation retrying with ExponentialBackOff instead of ExponentialRandomBackOff when randomExpression provided #427

Closed
@aftabshk

Description

@aftabshk

I am using following versions:

Java - 17
Spring Retry - 2.0.5
Spring Boot - 3.2.5
Example code to reproduce issue: spring-retry-issue

When I am using the @retryable annotation like following on any method:

@Retryable(retryFor = {RuntimeException.class}, maxAttempts = 10, backoff = @Backoff(delay = 2000, multiplier = 2, random = true))

Everything works as expected. I get 10 retries exponentially, increasing and with randomness in time. But, when I use the exact same values but pass them via application.properties as follows:

@Retryable(retryFor = {RuntimeException.class}, maxAttemptsExpression = "${retry.max-attempts}", backoff = @Backoff(delayExpression = "${retry.delay}", multiplierExpression = "${retry.multiplier}", randomExpression = "${retry.random}"))

Then I get 10 retries but only exponentially increasing and no randomness in time

You can see the example code here: spring-retry-issue

I have identified the issue in the code of the spring-retry library and raised a corresponding Pull Request for the same.
Here it is: Pull request 428
Please have a look and let me know if this works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions