File tree Expand file tree Collapse file tree 1 file changed +6
-20
lines changed
spring-core/src/main/java/org/springframework/core/retry Expand file tree Collapse file tree 1 file changed +6
-20
lines changed Original file line number Diff line number Diff line change 25
25
import org .jspecify .annotations .Nullable ;
26
26
27
27
import org .springframework .util .Assert ;
28
+ import org .springframework .util .ExceptionTypeFilter ;
28
29
29
30
/**
30
31
* Default {@link RetryPolicy} created by {@link RetryPolicy.Builder}.
31
32
*
32
33
* @author Sam Brannen
33
34
* @author Mahmoud Ben Hassine
35
+ * @author Mengqi Xu
34
36
* @since 7.0
35
37
*/
36
38
class DefaultRetryPolicy implements RetryPolicy {
@@ -105,6 +107,8 @@ private class DefaultRetryPolicyExecution implements RetryExecution {
105
107
106
108
private int retryCount ;
107
109
110
+ private final ExceptionTypeFilter exceptionTypeFilter = new ExceptionTypeFilter (DefaultRetryPolicy .this .includes ,
111
+ DefaultRetryPolicy .this .excludes , true );
108
112
109
113
@ Override
110
114
public boolean shouldRetry (Throwable throwable ) {
@@ -118,26 +122,8 @@ public boolean shouldRetry(Throwable throwable) {
118
122
return false ;
119
123
}
120
124
}
121
- if (!DefaultRetryPolicy .this .excludes .isEmpty ()) {
122
- for (Class <? extends Throwable > excludedType : DefaultRetryPolicy .this .excludes ) {
123
- if (excludedType .isInstance (throwable )) {
124
- return false ;
125
- }
126
- }
127
- }
128
- if (!DefaultRetryPolicy .this .includes .isEmpty ()) {
129
- boolean included = false ;
130
- for (Class <? extends Throwable > includedType : DefaultRetryPolicy .this .includes ) {
131
- if (includedType .isInstance (throwable )) {
132
- included = true ;
133
- break ;
134
- }
135
- }
136
- if (!included ) {
137
- return false ;
138
- }
139
- }
140
- return DefaultRetryPolicy .this .predicate == null || DefaultRetryPolicy .this .predicate .test (throwable );
125
+ return this .exceptionTypeFilter .match (throwable .getClass ()) &&
126
+ (DefaultRetryPolicy .this .predicate == null || DefaultRetryPolicy .this .predicate .test (throwable ));
141
127
}
142
128
143
129
@ Override
You can’t perform that action at this time.
0 commit comments