Browse Source

Polish contribution

See gh-35109
pull/35163/head
Sam Brannen 6 months ago
parent
commit
58061ae295
  1. 4
      spring-context/src/main/java/org/springframework/resilience/retry/MethodRetrySpec.java
  2. 7
      spring-core/src/main/java/org/springframework/core/retry/DefaultRetryPolicy.java

4
spring-context/src/main/java/org/springframework/resilience/retry/MethodRetrySpec.java

@ -64,8 +64,8 @@ public record MethodRetrySpec( @@ -64,8 +64,8 @@ public record MethodRetrySpec(
MethodRetryPredicate combinedPredicate() {
return (method, throwable) -> new ExceptionTypeFilter(this.includes, this.excludes, true)
.match(throwable.getClass()) &&
ExceptionTypeFilter exceptionFilter = new ExceptionTypeFilter(this.includes, this.excludes, true);
return (method, throwable) -> exceptionFilter.match(throwable.getClass()) &&
this.predicate.shouldRetry(method, throwable);
}

7
spring-core/src/main/java/org/springframework/core/retry/DefaultRetryPolicy.java

@ -38,6 +38,8 @@ class DefaultRetryPolicy implements RetryPolicy { @@ -38,6 +38,8 @@ class DefaultRetryPolicy implements RetryPolicy {
private final Set<Class<? extends Throwable>> excludes;
private final ExceptionTypeFilter exceptionFilter;
private final @Nullable Predicate<Throwable> predicate;
private final BackOff backOff;
@ -49,6 +51,7 @@ class DefaultRetryPolicy implements RetryPolicy { @@ -49,6 +51,7 @@ class DefaultRetryPolicy implements RetryPolicy {
this.includes = includes;
this.excludes = excludes;
this.exceptionFilter = new ExceptionTypeFilter(this.includes, this.excludes, true);
this.predicate = predicate;
this.backOff = backOff;
}
@ -56,9 +59,7 @@ class DefaultRetryPolicy implements RetryPolicy { @@ -56,9 +59,7 @@ class DefaultRetryPolicy implements RetryPolicy {
@Override
public boolean shouldRetry(Throwable throwable) {
ExceptionTypeFilter exceptionTypeFilter = new ExceptionTypeFilter(this.includes,
this.excludes, true);
return exceptionTypeFilter.match(throwable.getClass()) &&
return this.exceptionFilter.match(throwable.getClass()) &&
(this.predicate == null || this.predicate.test(throwable));
}

Loading…
Cancel
Save