Browse Source

Polish backoff and retry support

This revises commit 15dd320b95.

See gh-34529
See gh-35110
pull/35109/head
Sam Brannen 6 months ago
parent
commit
4cdfd90882
  1. 6
      spring-aop/src/main/java/org/springframework/aop/retry/MethodRetrySpec.java
  2. 7
      spring-aop/src/main/java/org/springframework/aop/retry/annotation/Retryable.java
  3. 2
      spring-core/src/main/java/org/springframework/util/backoff/ExponentialBackOff.java

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

@ -31,10 +31,10 @@ import java.util.Collections; @@ -31,10 +31,10 @@ import java.util.Collections;
* @param excludes non-applicable exception types to avoid a retry for
* @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 jitter a jitter value for the next retry attempt (in milliseconds)
* @param delay the base delay after the initial invocation
* @param jitter a jitter value for the next retry attempt
* @param multiplier a multiplier for a delay for the next retry attempt
* @param maxDelay the maximum delay for any retry attempt (in milliseconds)
* @param maxDelay the maximum delay for any retry attempt
* @see AbstractRetryInterceptor#getRetrySpec
* @see SimpleRetryInterceptor#SimpleRetryInterceptor(MethodRetrySpec)
* @see org.springframework.aop.retry.annotation.Retryable

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

@ -43,6 +43,7 @@ import org.springframework.core.annotation.AliasFor; @@ -43,6 +43,7 @@ import org.springframework.core.annotation.AliasFor;
* @since 7.0
* @see RetryAnnotationBeanPostProcessor
* @see RetryAnnotationInterceptor
* @see org.springframework.core.retry.RetryPolicy
* @see org.springframework.core.retry.RetryTemplate
* @see reactor.core.publisher.Mono#retryWhen
* @see reactor.core.publisher.Flux#retryWhen
@ -95,8 +96,8 @@ public @interface Retryable { @@ -95,8 +96,8 @@ public @interface Retryable {
long maxAttempts() default 3;
/**
* The base delay after the initial invocation in milliseconds. If a multiplier
* is specified, this serves as the initial delay to multiply from.
* The base delay after the initial invocation. If a multiplier is specified,
* this serves as the initial delay to multiply from.
* <p>The time unit is milliseconds by default but can be overridden via
* {@link #timeUnit}.
* <p>The default is 1000.
@ -147,7 +148,7 @@ public @interface Retryable { @@ -147,7 +148,7 @@ public @interface Retryable {
/**
* The {@link TimeUnit} to use for {@link #delay}, {@link #jitter},
* and {@link #maxDelay}.
* <p>Defaults to {@link TimeUnit#MILLISECONDS}.
* <p>The default is {@link TimeUnit#MILLISECONDS}.
*/
TimeUnit timeUnit() default TimeUnit.MILLISECONDS;

2
spring-core/src/main/java/org/springframework/util/backoff/ExponentialBackOff.java

@ -90,7 +90,7 @@ public class ExponentialBackOff implements BackOff { @@ -90,7 +90,7 @@ public class ExponentialBackOff implements BackOff {
* The default maximum attempts: unlimited.
* @since 6.1
*/
public static final int DEFAULT_MAX_ATTEMPTS = Integer.MAX_VALUE;
public static final long DEFAULT_MAX_ATTEMPTS = Long.MAX_VALUE;
private long initialInterval = DEFAULT_INITIAL_INTERVAL;

Loading…
Cancel
Save