File tree Expand file tree Collapse file tree 4 files changed +9
-15
lines changed
main/java/org/springframework/core/retry/support
test/java/org/springframework/core/retry Expand file tree Collapse file tree 4 files changed +9
-15
lines changed Original file line number Diff line number Diff line change 27
27
* @author Sam Brannen
28
28
* @since 7.0
29
29
*/
30
- public class MaxRetryAttemptsPolicy implements RetryPolicy {
30
+ public final class MaxRetryAttemptsPolicy implements RetryPolicy {
31
31
32
32
/**
33
33
* The default maximum number of retry attempts: {@value}.
Original file line number Diff line number Diff line change 30
30
* @author Sam Brannen
31
31
* @since 7.0
32
32
*/
33
- public class MaxRetryDurationPolicy implements RetryPolicy {
33
+ public final class MaxRetryDurationPolicy implements RetryPolicy {
34
34
35
35
/**
36
36
* The default maximum retry duration: 3 seconds.
Original file line number Diff line number Diff line change 28
28
* @author Sam Brannen
29
29
* @since 7.0
30
30
*/
31
- public class PredicateRetryPolicy implements RetryPolicy {
31
+ public final class PredicateRetryPolicy implements RetryPolicy {
32
32
33
33
private final Predicate <Throwable > predicate ;
34
34
Original file line number Diff line number Diff line change 20
20
21
21
import org .junit .jupiter .api .Test ;
22
22
23
- import org .springframework .core .retry .support .MaxRetryAttemptsPolicy ;
24
23
import org .springframework .util .backoff .FixedBackOff ;
25
24
26
25
import static org .assertj .core .api .Assertions .assertThat ;
@@ -110,20 +109,15 @@ public String getName() {
110
109
}
111
110
};
112
111
113
- MaxRetryAttemptsPolicy retryPolicy = new MaxRetryAttemptsPolicy () {
114
- @ Override
115
- public RetryExecution start () {
116
- return new RetryExecution () {
117
-
118
- int retryAttempts ;
112
+ RetryPolicy retryPolicy = () -> new RetryExecution () {
113
+ int retryAttempts ;
119
114
120
- @ Override
121
- public boolean shouldRetry (Throwable throwable ) {
122
- return this .retryAttempts ++ < 3 && throwable instanceof TechnicalException ;
123
- }
124
- };
115
+ @ Override
116
+ public boolean shouldRetry (Throwable throwable ) {
117
+ return (this .retryAttempts ++ < 3 && throwable instanceof TechnicalException );
125
118
}
126
119
};
120
+
127
121
retryTemplate .setRetryPolicy (retryPolicy );
128
122
retryTemplate .setBackOffPolicy (new FixedBackOff (Duration .ofMillis (10 )));
129
123
You can’t perform that action at this time.
0 commit comments