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;
* @param excludes non-applicable exception types to avoid a retry for * @param excludes non-applicable exception types to avoid a retry for
* @param predicate a predicate for filtering exceptions from applicable methods * @param predicate a predicate for filtering exceptions from applicable methods
* @param maxAttempts the maximum number of retry attempts * @param maxAttempts the maximum number of retry attempts
* @param delay the base delay after the initial invocation (in milliseconds) * @param delay the base delay after the initial invocation
* @param jitter a jitter value for the next retry attempt (in milliseconds) * @param jitter a jitter value for the next retry attempt
* @param multiplier a multiplier for a delay 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 AbstractRetryInterceptor#getRetrySpec
* @see SimpleRetryInterceptor#SimpleRetryInterceptor(MethodRetrySpec) * @see SimpleRetryInterceptor#SimpleRetryInterceptor(MethodRetrySpec)
* @see org.springframework.aop.retry.annotation.Retryable * @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;
* @since 7.0 * @since 7.0
* @see RetryAnnotationBeanPostProcessor * @see RetryAnnotationBeanPostProcessor
* @see RetryAnnotationInterceptor * @see RetryAnnotationInterceptor
* @see org.springframework.core.retry.RetryPolicy
* @see org.springframework.core.retry.RetryTemplate * @see org.springframework.core.retry.RetryTemplate
* @see reactor.core.publisher.Mono#retryWhen * @see reactor.core.publisher.Mono#retryWhen
* @see reactor.core.publisher.Flux#retryWhen * @see reactor.core.publisher.Flux#retryWhen
@ -95,8 +96,8 @@ public @interface Retryable {
long maxAttempts() default 3; long maxAttempts() default 3;
/** /**
* The base delay after the initial invocation in milliseconds. If a multiplier * The base delay after the initial invocation. If a multiplier is specified,
* is specified, this serves as the initial delay to multiply from. * this serves as the initial delay to multiply from.
* <p>The time unit is milliseconds by default but can be overridden via * <p>The time unit is milliseconds by default but can be overridden via
* {@link #timeUnit}. * {@link #timeUnit}.
* <p>The default is 1000. * <p>The default is 1000.
@ -147,7 +148,7 @@ public @interface Retryable {
/** /**
* The {@link TimeUnit} to use for {@link #delay}, {@link #jitter}, * The {@link TimeUnit} to use for {@link #delay}, {@link #jitter},
* and {@link #maxDelay}. * and {@link #maxDelay}.
* <p>Defaults to {@link TimeUnit#MILLISECONDS}. * <p>The default is {@link TimeUnit#MILLISECONDS}.
*/ */
TimeUnit timeUnit() default 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 {
* The default maximum attempts: unlimited. * The default maximum attempts: unlimited.
* @since 6.1 * @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; private long initialInterval = DEFAULT_INITIAL_INTERVAL;

Loading…
Cancel
Save