Skip to content

Commit 7cc29d2

Browse files
committed
Revise naming and docs for "jitter" and "multiplier" in AOP retry support
See gh-34529
1 parent 98b29b5 commit 7cc29d2

File tree

6 files changed

+30
-30
lines changed

6 files changed

+30
-30
lines changed

spring-aop/src/main/java/org/springframework/aop/retry/AbstractRetryInterceptor.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ public AbstractRetryInterceptor() {
104104

105105
ExponentialBackOff backOff = new ExponentialBackOff();
106106
backOff.setInitialInterval(spec.delay());
107-
backOff.setJitter(spec.jitterDelay());
108-
backOff.setMultiplier(spec.delayMultiplier());
107+
backOff.setJitter(spec.jitter());
108+
backOff.setMultiplier(spec.multiplier());
109109
backOff.setMaxInterval(spec.maxDelay());
110110
backOff.setMaxAttempts(spec.maxAttempts());
111111
retryTemplate.setBackOffPolicy(backOff);
@@ -147,8 +147,8 @@ public static Object adaptReactiveResult(
147147

148148
Publisher<?> publisher = adapter.toPublisher(result);
149149
Retry retry = Retry.backoff(spec.maxAttempts(), Duration.ofMillis(spec.delay()))
150-
.jitter((double) spec.jitterDelay() / spec.delay())
151-
.multiplier(spec.delayMultiplier())
150+
.jitter((double) spec.jitter() / spec.delay())
151+
.multiplier(spec.multiplier())
152152
.maxBackoff(Duration.ofMillis(spec.maxDelay()))
153153
.filter(spec.combinedPredicate().forMethod(method));
154154
publisher = (adapter.isMultiValue() ? Flux.from(publisher).retryWhen(retry) :

spring-aop/src/main/java/org/springframework/aop/retry/MethodRetrySpec.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
* @param predicate a predicate for filtering exceptions from applicable methods
3232
* @param maxAttempts the maximum number of retry attempts
3333
* @param delay the base delay after the initial invocation (in milliseconds)
34-
* @param jitterDelay a jitter delay for the next retry attempt (in milliseconds)
35-
* @param delayMultiplier a multiplier for a delay for the next retry attempt
34+
* @param jitter a jitter value for the next retry attempt (in milliseconds)
35+
* @param multiplier a multiplier for a delay for the next retry attempt
3636
* @param maxDelay the maximum delay for any retry attempt (in milliseconds)
3737
* @see AbstractRetryInterceptor#getRetrySpec
3838
* @see SimpleRetryInterceptor#SimpleRetryInterceptor(MethodRetrySpec)
@@ -44,19 +44,19 @@ public record MethodRetrySpec(
4444
MethodRetryPredicate predicate,
4545
int maxAttempts,
4646
long delay,
47-
long jitterDelay,
48-
double delayMultiplier,
47+
long jitter,
48+
double multiplier,
4949
long maxDelay) {
5050

5151
public MethodRetrySpec(MethodRetryPredicate predicate, int maxAttempts, long delay) {
5252
this(predicate, maxAttempts, delay, 0, 1.0, Integer.MAX_VALUE);
5353
}
5454

5555
public MethodRetrySpec(MethodRetryPredicate predicate, int maxAttempts, long delay,
56-
long jitterDelay, double delayMultiplier, long maxDelay) {
56+
long jitter, double multiplier, long maxDelay) {
5757

5858
this(Collections.emptyList(), Collections.emptyList(), predicate, maxAttempts, delay,
59-
jitterDelay, delayMultiplier, maxDelay);
59+
jitter, multiplier, maxDelay);
6060
}
6161

6262

spring-aop/src/main/java/org/springframework/aop/retry/annotation/RetryAnnotationInterceptor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ public class RetryAnnotationInterceptor extends AbstractRetryInterceptor {
6060
retrySpec = new MethodRetrySpec(
6161
Arrays.asList(retryable.includes()), Arrays.asList(retryable.excludes()),
6262
instantiatePredicate(retryable.predicate()), retryable.maxAttempts(),
63-
retryable.delay(), retryable.jitterDelay(),
64-
retryable.delayMultiplier(), retryable.maxDelay());
63+
retryable.delay(), retryable.jitter(),
64+
retryable.multiplier(), retryable.maxDelay());
6565

6666
MethodRetrySpec existing = this.retrySpecCache.putIfAbsent(cacheKey, retrySpec);
6767
return (existing != null ? existing : retrySpec);

spring-aop/src/main/java/org/springframework/aop/retry/annotation/Retryable.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -97,44 +97,44 @@
9797
* The base delay after the initial invocation in milliseconds.
9898
* If a multiplier is specified, this serves as the initial delay to multiply from.
9999
* <p>The default is 1000.
100-
* @see #jitterDelay()
101-
* @see #delayMultiplier()
100+
* @see #jitter()
101+
* @see #multiplier()
102102
* @see #maxDelay()
103103
*/
104104
long delay() default 1000;
105105

106106
/**
107-
* A jitter delay for the base retry attempt (in milliseconds), randomly
108-
* subtracted or added to the calculated delay, resulting in a value
109-
* between {@code delay - jitterDelay} and {@code delay + jitterDelay}
110-
* but never below the base {@link #delay()} or above {@link #maxDelay()}.
111-
* If a multiplier is specified, it applies to the jitter delay as well.
107+
* A jitter value (in milliseconds) for the base retry attempt, randomly
108+
* subtracted or added to the calculated delay, resulting in a value between
109+
* {@code delay - jitter} and {@code delay + jitter} but never below the base
110+
* {@link #delay()} or above {@link #maxDelay()}.
111+
* <p>If a multiplier is specified, it is applied to the jitter value as well.
112112
* <p>The default is 0 (no jitter).
113113
* @see #delay()
114-
* @see #delayMultiplier()
114+
* @see #multiplier()
115115
* @see #maxDelay()
116116
*/
117-
long jitterDelay() default 0;
117+
long jitter() default 0;
118118

119119
/**
120120
* A multiplier for a delay for the next retry attempt, applied
121121
* to the previous delay (starting with {@link #delay()}) as well
122-
* as to the applicable {@link #jitterDelay()} for each attempt.
122+
* as to the applicable {@link #jitter()} for each attempt.
123123
* <p>The default is 1.0, effectively resulting in a fixed delay.
124124
* @see #delay()
125-
* @see #jitterDelay()
125+
* @see #jitter()
126126
* @see #maxDelay()
127127
*/
128-
double delayMultiplier() default 1.0;
128+
double multiplier() default 1.0;
129129

130130
/**
131131
* The maximum delay for any retry attempt (in milliseconds), limiting
132-
* how far {@link #jitterDelay()} and {@link #delayMultiplier()} can
133-
* increase the {@linkplain #delay() delay}.
132+
* how far {@link #jitter()} and {@link #multiplier()} can increase the
133+
* {@linkplain #delay() delay}.
134134
* <p>The default is unlimited.
135135
* @see #delay()
136-
* @see #jitterDelay()
137-
* @see #delayMultiplier()
136+
* @see #jitter()
137+
* @see #multiplier()
138138
*/
139139
long maxDelay() default Integer.MAX_VALUE;
140140

spring-aop/src/test/java/org/springframework/aop/retry/ReactiveRetryInterceptorTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public Mono<Object> retryOperation() {
152152
}
153153

154154

155-
@Retryable(delay = 10, jitterDelay = 5, delayMultiplier = 2.0, maxDelay = 40,
155+
@Retryable(delay = 10, jitter = 5, multiplier = 2.0, maxDelay = 40,
156156
includes = IOException.class, excludes = AccessDeniedException.class,
157157
predicate = CustomPredicate.class)
158158
public static class AnnotatedClassBean {

spring-aop/src/test/java/org/springframework/aop/retry/RetryInterceptorTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public void retryOperation() throws IOException {
135135
}
136136

137137

138-
@Retryable(delay = 10, jitterDelay = 5, delayMultiplier = 2.0, maxDelay = 40,
138+
@Retryable(delay = 10, jitter = 5, multiplier = 2.0, maxDelay = 40,
139139
includes = IOException.class, excludes = AccessDeniedException.class,
140140
predicate = CustomPredicate.class)
141141
public static class AnnotatedClassBean {

0 commit comments

Comments
 (0)