Package dev.failsafe

Class RetryPolicyBuilder<R>

Type Parameters:
R - result type
All Implemented Interfaces:
PolicyListeners<RetryPolicyBuilder<R>,R>

public class RetryPolicyBuilder<R> extends DelayablePolicyBuilder<RetryPolicyBuilder<R>,RetryPolicyConfig<R>,R> implements PolicyListeners<RetryPolicyBuilder<R>,R>
Builds RetryPolicy instances.
  • By default, a RetryPolicy will retry up to 2 times when any Exception is thrown, with no delay between retry attempts.
  • You can change the default number of retry attempts and delay between retries by using the with configuration methods.
  • By default, any exception is considered a failure and will be handled by the policy. You can override this by specifying your own handle conditions. The default exception handling condition will only be overridden by another condition that handles exceptions such as FailurePolicyBuilder.handle(Class) or FailurePolicyBuilder.handleIf(CheckedBiPredicate). Specifying a condition that only handles results, such as FailurePolicyBuilder.handleResult(Object) or FailurePolicyBuilder.handleResultIf(CheckedPredicate) will not replace the default exception handling condition.
  • If multiple handle conditions are specified, any condition that matches an execution result or exception will trigger policy handling.
  • The abortOn, abortWhen and abortIf methods describe when retries should be aborted.

Note:

See Also: