diff --git a/src/main/java/org/springframework/retry/annotation/CircuitBreaker.java b/src/main/java/org/springframework/retry/annotation/CircuitBreaker.java index caa7bd63..6cdba247 100644 --- a/src/main/java/org/springframework/retry/annotation/CircuitBreaker.java +++ b/src/main/java/org/springframework/retry/annotation/CircuitBreaker.java @@ -40,10 +40,13 @@ public @interface CircuitBreaker { /** - * Exception types that are retryable. Synonym for includes(). Defaults to empty (and - * if excludes is also empty all exceptions are retried). + * Exception types that are retryable. Defaults to empty (and if excludes is also + * empty all exceptions are retried). * @return exception types to retry + * @deprecated in favor of {@link #retryFor()} */ + @AliasFor(annotation = Retryable.class) + @Deprecated Class[] value() default {}; /** @@ -52,7 +55,7 @@ * @return exception types to retry * @deprecated in favor of {@link #retryFor()}. */ - @AliasFor("retryFor") + @AliasFor(annotation = Retryable.class) @Deprecated Class[] include() default {}; @@ -62,7 +65,7 @@ * @return exception types to retry * @since 2.0 */ - @AliasFor("include") + @AliasFor(annotation = Retryable.class) Class[] retryFor() default {}; /** @@ -73,7 +76,7 @@ * @deprecated in favor of {@link #noRetryFor()}. */ @Deprecated - @AliasFor("noRetryFor") + @AliasFor(annotation = Retryable.class) Class[] exclude() default {}; /** @@ -83,7 +86,7 @@ * @return exception types not to retry * @since 2.0 */ - @AliasFor("exclude") + @AliasFor(annotation = Retryable.class) Class[] noRetryFor() default {}; /** @@ -93,11 +96,13 @@ * @return exception types not to retry * @since 2.0 */ + @AliasFor(annotation = Retryable.class) Class[] notRecoverable() default {}; /** * @return the maximum number of attempts (including the first failure), defaults to 3 */ + @AliasFor(annotation = Retryable.class) int maxAttempts() default 3; /** @@ -107,6 +112,7 @@ * at runtime. * @since 1.2.3 */ + @AliasFor(annotation = Retryable.class) String maxAttemptsExpression() default ""; /** @@ -114,6 +120,7 @@ * method signature where the annotation is declared. * @return the label for the circuit */ + @AliasFor(annotation = Retryable.class) String label() default ""; /** @@ -137,7 +144,7 @@ /** * When {@link #maxAttempts()} failures are reached within this timeout, the circuit * is opened automatically, preventing access to the downstream component. - * @return the timeout before an closed circuit is opened in milliseconds, defaults to + * @return the timeout before a closed circuit is opened in milliseconds, defaults to * 5000 */ long openTimeout() default 5000; @@ -147,7 +154,7 @@ * is opened automatically, preventing access to the downstream component. Overrides * {@link #openTimeout()}. Use {@code #{...}} for one-time evaluation during * initialization, omit the delimiters for evaluation at runtime. - * @return the timeout before an closed circuit is opened in milliseconds, no default. + * @return the timeout before a closed circuit is opened in milliseconds, no default. * @since 1.2.3 */ String openTimeoutExpression() default ""; @@ -171,6 +178,7 @@ * @return the expression. * @since 1.2.3 */ + @AliasFor(annotation = Retryable.class) String exceptionExpression() default ""; } diff --git a/src/main/java/org/springframework/retry/annotation/Retryable.java b/src/main/java/org/springframework/retry/annotation/Retryable.java index ae9af1f2..101c589c 100644 --- a/src/main/java/org/springframework/retry/annotation/Retryable.java +++ b/src/main/java/org/springframework/retry/annotation/Retryable.java @@ -54,8 +54,8 @@ String interceptor() default ""; /** - * Exception types that are retryable. Synonym for include(). Defaults to empty (and - * if excludes is also empty all exceptions are retried). + * Exception types that are retryable. Defaults to empty (and if excludes is also + * empty all exceptions are retried). * @return exception types to retry * @deprecated in favor of {@link #retryFor()} */ diff --git a/src/test/java/org/springframework/retry/annotation/CircuitBreakerResetTimeoutTests.java b/src/test/java/org/springframework/retry/annotation/CircuitBreakerResetTimeoutTests.java index 50599b17..29c536e2 100644 --- a/src/test/java/org/springframework/retry/annotation/CircuitBreakerResetTimeoutTests.java +++ b/src/test/java/org/springframework/retry/annotation/CircuitBreakerResetTimeoutTests.java @@ -87,7 +87,7 @@ static class TestService { private RetryContext context; - @CircuitBreaker(include = { RuntimeException.class }, openTimeout = 10000, resetTimeout = 15000) + @CircuitBreaker(retryFor = { RuntimeException.class }, openTimeout = 10000, resetTimeout = 15000) String service(String payload) { this.context = RetrySynchronizationManager.getContext(); System.out.println("real service called"); diff --git a/src/test/java/org/springframework/retry/annotation/CircuitBreakerTests.java b/src/test/java/org/springframework/retry/annotation/CircuitBreakerTests.java index 95ca1862..a6b2339c 100644 --- a/src/test/java/org/springframework/retry/annotation/CircuitBreakerTests.java +++ b/src/test/java/org/springframework/retry/annotation/CircuitBreakerTests.java @@ -166,7 +166,7 @@ protected static class ServiceImpl implements Service { RetryContext context; @Override - @CircuitBreaker(RuntimeException.class) + @CircuitBreaker(retryFor = RuntimeException.class) public void service() { this.context = RetrySynchronizationManager.getContext(); if (this.count++ < 5) {