mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-23 22:59:03 +00:00
Polish core retry internals
This commit is contained in:
@@ -44,7 +44,7 @@ import java.util.Objects;
|
||||
public class RetryException extends Exception {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 5439915454935047936L;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.core.retry;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Deque;
|
||||
|
||||
@@ -148,7 +149,7 @@ public class RetryTemplate implements RetryOperations {
|
||||
.formatted(retryableName));
|
||||
// Retry process starts here
|
||||
BackOffExecution backOffExecution = this.retryPolicy.getBackOff().start();
|
||||
Deque<Throwable> exceptions = new ArrayDeque<>();
|
||||
Deque<Throwable> exceptions = new ArrayDeque<>(4);
|
||||
exceptions.add(initialException);
|
||||
|
||||
Throwable lastException = initialException;
|
||||
@@ -200,8 +201,10 @@ public class RetryTemplate implements RetryOperations {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class RetryInterruptedException extends RetryException {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -213,7 +216,6 @@ public class RetryTemplate implements RetryOperations {
|
||||
public int getRetryCount() {
|
||||
return (getSuppressed().length - 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-1
@@ -46,6 +46,7 @@ public class CompositeRetryListener implements RetryListener {
|
||||
|
||||
/**
|
||||
* Create a new {@code CompositeRetryListener}.
|
||||
* @see #addListener(RetryListener)
|
||||
*/
|
||||
public CompositeRetryListener() {
|
||||
}
|
||||
@@ -56,7 +57,7 @@ public class CompositeRetryListener implements RetryListener {
|
||||
* @param listeners the list of delegate listeners to register; must not be empty
|
||||
*/
|
||||
public CompositeRetryListener(List<RetryListener> listeners) {
|
||||
Assert.notEmpty(listeners, "RetryListener List must not be empty");
|
||||
Assert.notEmpty(listeners, "RetryListener list must not be empty");
|
||||
this.listeners.addAll(listeners);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user