Skip to content

Commit 58061ae

Browse files
committed
Polish contribution
See gh-35109
1 parent 489ebd2 commit 58061ae

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ public MethodRetrySpec(MethodRetryPredicate predicate, long maxAttempts, Duratio
6464

6565

6666
MethodRetryPredicate combinedPredicate() {
67-
return (method, throwable) -> new ExceptionTypeFilter(this.includes, this.excludes, true)
68-
.match(throwable.getClass()) &&
67+
ExceptionTypeFilter exceptionFilter = new ExceptionTypeFilter(this.includes, this.excludes, true);
68+
return (method, throwable) -> exceptionFilter.match(throwable.getClass()) &&
6969
this.predicate.shouldRetry(method, throwable);
7070
}
7171

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ class DefaultRetryPolicy implements RetryPolicy {
3838

3939
private final Set<Class<? extends Throwable>> excludes;
4040

41+
private final ExceptionTypeFilter exceptionFilter;
42+
4143
private final @Nullable Predicate<Throwable> predicate;
4244

4345
private final BackOff backOff;
@@ -49,16 +51,15 @@ class DefaultRetryPolicy implements RetryPolicy {
4951

5052
this.includes = includes;
5153
this.excludes = excludes;
54+
this.exceptionFilter = new ExceptionTypeFilter(this.includes, this.excludes, true);
5255
this.predicate = predicate;
5356
this.backOff = backOff;
5457
}
5558

5659

5760
@Override
5861
public boolean shouldRetry(Throwable throwable) {
59-
ExceptionTypeFilter exceptionTypeFilter = new ExceptionTypeFilter(this.includes,
60-
this.excludes, true);
61-
return exceptionTypeFilter.match(throwable.getClass()) &&
62+
return this.exceptionFilter.match(throwable.getClass()) &&
6263
(this.predicate == null || this.predicate.test(throwable));
6364
}
6465

0 commit comments

Comments
 (0)