Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<? extends Throwable>[] value() default {};

/**
Expand All @@ -52,7 +55,7 @@
* @return exception types to retry
* @deprecated in favor of {@link #retryFor()}.
*/
@AliasFor("retryFor")
@AliasFor(annotation = Retryable.class)
@Deprecated
Class<? extends Throwable>[] include() default {};

Expand All @@ -62,7 +65,7 @@
* @return exception types to retry
* @since 2.0
*/
@AliasFor("include")
@AliasFor(annotation = Retryable.class)
Class<? extends Throwable>[] retryFor() default {};

/**
Expand All @@ -73,7 +76,7 @@
* @deprecated in favor of {@link #noRetryFor()}.
*/
@Deprecated
@AliasFor("noRetryFor")
@AliasFor(annotation = Retryable.class)
Class<? extends Throwable>[] exclude() default {};

/**
Expand All @@ -83,7 +86,7 @@
* @return exception types not to retry
* @since 2.0
*/
@AliasFor("exclude")
@AliasFor(annotation = Retryable.class)
Class<? extends Throwable>[] noRetryFor() default {};

/**
Expand All @@ -93,11 +96,13 @@
* @return exception types not to retry
* @since 2.0
*/
@AliasFor(annotation = Retryable.class)
Class<? extends Throwable>[] notRecoverable() default {};

/**
* @return the maximum number of attempts (including the first failure), defaults to 3
*/
@AliasFor(annotation = Retryable.class)
int maxAttempts() default 3;

/**
Expand All @@ -107,13 +112,15 @@
* at runtime.
* @since 1.2.3
*/
@AliasFor(annotation = Retryable.class)
String maxAttemptsExpression() default "";

/**
* A unique label for the circuit for reporting and state management. Defaults to the
* method signature where the annotation is declared.
* @return the label for the circuit
*/
@AliasFor(annotation = Retryable.class)
String label() default "";

/**
Expand All @@ -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;
Expand All @@ -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 "";
Expand All @@ -171,6 +178,7 @@
* @return the expression.
* @since 1.2.3
*/
@AliasFor(annotation = Retryable.class)
String exceptionExpression() default "";

}
Original file line number Diff line number Diff line change
Expand Up @@ -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()}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down