spring-retry icon indicating copy to clipboard operation
spring-retry copied to clipboard

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

Open aftabshk opened this issue 1 year ago • 1 comments

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.

aftabshk avatar Apr 27 '24 18:04 aftabshk

您好,我已经收到您的邮件,将尽快给您回复。

gaofengIt avatar Apr 27 '24 18:04 gaofengIt