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 2727 * @author Sam Brannen
2828 * @since 7.0
2929 */
30- public class MaxRetryAttemptsPolicy implements RetryPolicy {
30+ public final class MaxRetryAttemptsPolicy implements RetryPolicy {
3131
3232 /**
3333 * The default maximum number of retry attempts: {@value}.
Original file line number Diff line number Diff line change 3030 * @author Sam Brannen
3131 * @since 7.0
3232 */
33- public class MaxRetryDurationPolicy implements RetryPolicy {
33+ public final class MaxRetryDurationPolicy implements RetryPolicy {
3434
3535 /**
3636 * The default maximum retry duration: 3 seconds.
Original file line number Diff line number Diff line change 2828 * @author Sam Brannen
2929 * @since 7.0
3030 */
31- public class PredicateRetryPolicy implements RetryPolicy {
31+ public final class PredicateRetryPolicy implements RetryPolicy {
3232
3333 private final Predicate <Throwable > predicate ;
3434
Original file line number Diff line number Diff line change 2020
2121import org .junit .jupiter .api .Test ;
2222
23- import org .springframework .core .retry .support .MaxRetryAttemptsPolicy ;
2423import org .springframework .util .backoff .FixedBackOff ;
2524
2625import static org .assertj .core .api .Assertions .assertThat ;
@@ -110,20 +109,15 @@ public String getName() {
110109 }
111110 };
112111
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 ;
119114
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 );
125118 }
126119 };
120+
127121 retryTemplate .setRetryPolicy (retryPolicy );
128122 retryTemplate .setBackOffPolicy (new FixedBackOff (Duration .ofMillis (10 )));
129123
You can’t perform that action at this time.
0 commit comments