public final class RetryUtils extends Object
Modifier and Type | Class and Description |
---|---|
static class |
RetryUtils.RetryPolicy
This class encapsulates a retry policy.
|
Modifier and Type | Field and Description |
---|---|
static RetryUtils.RetryPolicy |
DEFAULT_RETRY_POLICY
Default retry policy used by
withRetry(Callable) . |
Modifier and Type | Method and Description |
---|---|
static RetryUtils.RetryPolicy.Builder |
retryPolicyBuilder()
This method returns a RetryPolicy.Builder.
|
static <T> T |
withRetry(Callable<T> action)
This method attempts to execute a given action up to a specified number of times with a 1-second delay.
|
static <T> T |
withRetry(Callable<T> action,
int maxAttempts)
This method attempts to execute a given action up to a specified number of times with a 1-second delay.
|
public static final RetryUtils.RetryPolicy DEFAULT_RETRY_POLICY
withRetry(Callable)
.public static RetryUtils.RetryPolicy.Builder retryPolicyBuilder()
public static <T> T withRetry(Callable<T> action, int maxAttempts)
T
- The type of the result of the action.action
- The action to be executed.maxAttempts
- The maximum number of attempts to execute the action.RuntimeException
- if the action fails on all attempts.public static <T> T withRetry(Callable<T> action)
T
- The type of the result of the action.action
- The action to be executed.RuntimeException
- if the action fails on all attempts.Copyright © 2024. All rights reserved.