Skip to content

Commit 8979bb8

Browse files
committed
Filter throwable by ExceptionTypeFilter.
Signed-off-by: Mengqi Xu <2663479778@qq.com>
1 parent 21c74ce commit 8979bb8

File tree

1 file changed

+5
-22
lines changed

1 file changed

+5
-22
lines changed

spring-aop/src/main/java/org/springframework/aop/retry/MethodRetrySpec.java

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import java.util.Collection;
2020
import java.util.Collections;
2121

22+
import org.springframework.util.ExceptionTypeFilter;
23+
2224
/**
2325
* A specification for retry attempts on a given method, combining common
2426
* retry characteristics. This roughly matches the annotation attributes
@@ -61,28 +63,9 @@ public MethodRetrySpec(MethodRetryPredicate predicate, int maxAttempts, long del
6163

6264

6365
MethodRetryPredicate combinedPredicate() {
64-
return (method, throwable) -> {
65-
if (!this.excludes.isEmpty()) {
66-
for (Class<? extends Throwable> exclude : this.excludes) {
67-
if (exclude.isInstance(throwable)) {
68-
return false;
69-
}
70-
}
71-
}
72-
if (!this.includes.isEmpty()) {
73-
boolean included = false;
74-
for (Class<? extends Throwable> include : this.includes) {
75-
if (include.isInstance(throwable)) {
76-
included = true;
77-
break;
78-
}
79-
}
80-
if (!included) {
81-
return false;
82-
}
83-
}
84-
return this.predicate.shouldRetry(method, throwable);
85-
};
66+
return (method, throwable) -> new ExceptionTypeFilter(this.includes, this.excludes, true)
67+
.match(throwable.getClass()) &&
68+
this.predicate.shouldRetry(method, throwable);
8669
}
8770

8871
}

0 commit comments

Comments
 (0)