Repository navigation
Conversation
The default maxDelay of `@Retryable` is Long.MAX_VALUE, which was converted to a Duration in the configured timeUnit. With SECONDS this overflowed in RetryPolicy.Builder.build() and with MINUTES or larger already in Duration.of(), so every invocation of a method declaring for example `@Retryable(delay = 1, timeUnit = TimeUnit.SECONDS)` failed with an ArithmeticException. Convert with TimeUnit.toMillis(), which saturates instead of overflowing, so that the default as well as any other large value is treated as unlimited, consistent with MethodRetrySpec. Units finer than milliseconds keep using Duration.of() to preserve precision. Closes spring-projectsgh-37525 Signed-off-by: Seungtaek Lim <namest504@gmail.com>
sbrannen
force-pushed
the
retryable-timeunit-default-max-delay
branch
from
October 20, 2026 10:13
ef5a8c0 to
982d021
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The default
maxDelayof@RetryableisLong.MAX_VALUE, meant as "unlimited".RetryAnnotationBeanPostProcessorconverts it using the configuredtimeUnit, so withtimeUnit = TimeUnit.SECONDSthe conversion to milliseconds inRetryPolicy.Builder.build()overflows, and withMINUTESor largerDuration.of()itself overflows.As a result, any method declaring for example
fails on every invocation with
ArithmeticException: long overflowbefore the target method is invoked, even if the first attempt would succeed. Reproduced with a Spring Boot 4.0.8 application (Spring Framework 7.0.9) and onmain; the same applies to 7.0.x.This change converts the attributes with
TimeUnit.toMillis(), which saturates instead of overflowing, so that the default as well as any other large value is treated as unlimited, consistent with the defaultmaxDelayinMethodRetrySpec. Units finer than milliseconds keep usingDuration.of()to preserve precision. The added test coversSECONDS,MINUTES, and an explicit largemaxDelay.