diff --git a/spring-aop/src/main/java/org/springframework/aop/retry/AbstractRetryInterceptor.java b/spring-aop/src/main/java/org/springframework/aop/retry/AbstractRetryInterceptor.java index 11dd2609d2..def93cb7c2 100644 --- a/spring-aop/src/main/java/org/springframework/aop/retry/AbstractRetryInterceptor.java +++ b/spring-aop/src/main/java/org/springframework/aop/retry/AbstractRetryInterceptor.java @@ -104,8 +104,8 @@ public abstract class AbstractRetryInterceptor implements MethodInterceptor { ExponentialBackOff backOff = new ExponentialBackOff(); backOff.setInitialInterval(spec.delay()); - backOff.setJitter(spec.jitterDelay()); - backOff.setMultiplier(spec.delayMultiplier()); + backOff.setJitter(spec.jitter()); + backOff.setMultiplier(spec.multiplier()); backOff.setMaxInterval(spec.maxDelay()); backOff.setMaxAttempts(spec.maxAttempts()); retryTemplate.setBackOffPolicy(backOff); @@ -147,8 +147,8 @@ public abstract class AbstractRetryInterceptor implements MethodInterceptor { Publisher publisher = adapter.toPublisher(result); Retry retry = Retry.backoff(spec.maxAttempts(), Duration.ofMillis(spec.delay())) - .jitter((double) spec.jitterDelay() / spec.delay()) - .multiplier(spec.delayMultiplier()) + .jitter((double) spec.jitter() / spec.delay()) + .multiplier(spec.multiplier()) .maxBackoff(Duration.ofMillis(spec.maxDelay())) .filter(spec.combinedPredicate().forMethod(method)); publisher = (adapter.isMultiValue() ? Flux.from(publisher).retryWhen(retry) : diff --git a/spring-aop/src/main/java/org/springframework/aop/retry/MethodRetrySpec.java b/spring-aop/src/main/java/org/springframework/aop/retry/MethodRetrySpec.java index 919648fc5c..ff0e8060ba 100644 --- a/spring-aop/src/main/java/org/springframework/aop/retry/MethodRetrySpec.java +++ b/spring-aop/src/main/java/org/springframework/aop/retry/MethodRetrySpec.java @@ -31,8 +31,8 @@ import java.util.Collections; * @param predicate a predicate for filtering exceptions from applicable methods * @param maxAttempts the maximum number of retry attempts * @param delay the base delay after the initial invocation (in milliseconds) - * @param jitterDelay a jitter delay for the next retry attempt (in milliseconds) - * @param delayMultiplier a multiplier for a delay for the next retry attempt + * @param jitter a jitter value for the next retry attempt (in milliseconds) + * @param multiplier a multiplier for a delay for the next retry attempt * @param maxDelay the maximum delay for any retry attempt (in milliseconds) * @see AbstractRetryInterceptor#getRetrySpec * @see SimpleRetryInterceptor#SimpleRetryInterceptor(MethodRetrySpec) @@ -44,8 +44,8 @@ public record MethodRetrySpec( MethodRetryPredicate predicate, int maxAttempts, long delay, - long jitterDelay, - double delayMultiplier, + long jitter, + double multiplier, long maxDelay) { public MethodRetrySpec(MethodRetryPredicate predicate, int maxAttempts, long delay) { @@ -53,10 +53,10 @@ public record MethodRetrySpec( } public MethodRetrySpec(MethodRetryPredicate predicate, int maxAttempts, long delay, - long jitterDelay, double delayMultiplier, long maxDelay) { + long jitter, double multiplier, long maxDelay) { this(Collections.emptyList(), Collections.emptyList(), predicate, maxAttempts, delay, - jitterDelay, delayMultiplier, maxDelay); + jitter, multiplier, maxDelay); } diff --git a/spring-aop/src/main/java/org/springframework/aop/retry/annotation/RetryAnnotationInterceptor.java b/spring-aop/src/main/java/org/springframework/aop/retry/annotation/RetryAnnotationInterceptor.java index 9accdaf6b5..99b27c1d01 100644 --- a/spring-aop/src/main/java/org/springframework/aop/retry/annotation/RetryAnnotationInterceptor.java +++ b/spring-aop/src/main/java/org/springframework/aop/retry/annotation/RetryAnnotationInterceptor.java @@ -60,8 +60,8 @@ public class RetryAnnotationInterceptor extends AbstractRetryInterceptor { retrySpec = new MethodRetrySpec( Arrays.asList(retryable.includes()), Arrays.asList(retryable.excludes()), instantiatePredicate(retryable.predicate()), retryable.maxAttempts(), - retryable.delay(), retryable.jitterDelay(), - retryable.delayMultiplier(), retryable.maxDelay()); + retryable.delay(), retryable.jitter(), + retryable.multiplier(), retryable.maxDelay()); MethodRetrySpec existing = this.retrySpecCache.putIfAbsent(cacheKey, retrySpec); return (existing != null ? existing : retrySpec); diff --git a/spring-aop/src/main/java/org/springframework/aop/retry/annotation/Retryable.java b/spring-aop/src/main/java/org/springframework/aop/retry/annotation/Retryable.java index 9285a5900c..fc036e3df9 100644 --- a/spring-aop/src/main/java/org/springframework/aop/retry/annotation/Retryable.java +++ b/spring-aop/src/main/java/org/springframework/aop/retry/annotation/Retryable.java @@ -97,44 +97,44 @@ public @interface Retryable { * The base delay after the initial invocation in milliseconds. * If a multiplier is specified, this serves as the initial delay to multiply from. *

The default is 1000. - * @see #jitterDelay() - * @see #delayMultiplier() + * @see #jitter() + * @see #multiplier() * @see #maxDelay() */ long delay() default 1000; /** - * A jitter delay for the base retry attempt (in milliseconds), randomly - * subtracted or added to the calculated delay, resulting in a value - * between {@code delay - jitterDelay} and {@code delay + jitterDelay} - * but never below the base {@link #delay()} or above {@link #maxDelay()}. - * If a multiplier is specified, it applies to the jitter delay as well. + * A jitter value (in milliseconds) for the base retry attempt, randomly + * subtracted or added to the calculated delay, resulting in a value between + * {@code delay - jitter} and {@code delay + jitter} but never below the base + * {@link #delay()} or above {@link #maxDelay()}. + *

If a multiplier is specified, it is applied to the jitter value as well. *

The default is 0 (no jitter). * @see #delay() - * @see #delayMultiplier() + * @see #multiplier() * @see #maxDelay() */ - long jitterDelay() default 0; + long jitter() default 0; /** * A multiplier for a delay for the next retry attempt, applied * to the previous delay (starting with {@link #delay()}) as well - * as to the applicable {@link #jitterDelay()} for each attempt. + * as to the applicable {@link #jitter()} for each attempt. *

The default is 1.0, effectively resulting in a fixed delay. * @see #delay() - * @see #jitterDelay() + * @see #jitter() * @see #maxDelay() */ - double delayMultiplier() default 1.0; + double multiplier() default 1.0; /** * The maximum delay for any retry attempt (in milliseconds), limiting - * how far {@link #jitterDelay()} and {@link #delayMultiplier()} can - * increase the {@linkplain #delay() delay}. + * how far {@link #jitter()} and {@link #multiplier()} can increase the + * {@linkplain #delay() delay}. *

The default is unlimited. * @see #delay() - * @see #jitterDelay() - * @see #delayMultiplier() + * @see #jitter() + * @see #multiplier() */ long maxDelay() default Integer.MAX_VALUE; diff --git a/spring-aop/src/test/java/org/springframework/aop/retry/ReactiveRetryInterceptorTests.java b/spring-aop/src/test/java/org/springframework/aop/retry/ReactiveRetryInterceptorTests.java index 15d999c02c..87ead86fe1 100644 --- a/spring-aop/src/test/java/org/springframework/aop/retry/ReactiveRetryInterceptorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/retry/ReactiveRetryInterceptorTests.java @@ -152,7 +152,7 @@ public class ReactiveRetryInterceptorTests { } - @Retryable(delay = 10, jitterDelay = 5, delayMultiplier = 2.0, maxDelay = 40, + @Retryable(delay = 10, jitter = 5, multiplier = 2.0, maxDelay = 40, includes = IOException.class, excludes = AccessDeniedException.class, predicate = CustomPredicate.class) public static class AnnotatedClassBean { diff --git a/spring-aop/src/test/java/org/springframework/aop/retry/RetryInterceptorTests.java b/spring-aop/src/test/java/org/springframework/aop/retry/RetryInterceptorTests.java index 569b648b56..19df78a2c7 100644 --- a/spring-aop/src/test/java/org/springframework/aop/retry/RetryInterceptorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/retry/RetryInterceptorTests.java @@ -135,7 +135,7 @@ public class RetryInterceptorTests { } - @Retryable(delay = 10, jitterDelay = 5, delayMultiplier = 2.0, maxDelay = 40, + @Retryable(delay = 10, jitter = 5, multiplier = 2.0, maxDelay = 40, includes = IOException.class, excludes = AccessDeniedException.class, predicate = CustomPredicate.class) public static class AnnotatedClassBean {