@ThreadSafe public interface RetryStrategy
We do not recommend SDK users create their own retry strategies. We recommend refining an existing strategy:
[ServiceName]Client.defaults().retryStrategy().
RetryStrategies from the com.ibm.cos.v2:retries module.
Terminology:
| Modifier and Type | Interface and Description |
|---|---|
static interface |
RetryStrategy.Builder<B extends RetryStrategy.Builder<B,T>,T extends RetryStrategy>
Builder to create immutable instances of
RetryStrategy. |
| Modifier and Type | Method and Description |
|---|---|
AcquireInitialTokenResponse |
acquireInitialToken(AcquireInitialTokenRequest request)
Invoked before the first request attempt.
|
int |
maxAttempts()
Returns the maximum numbers attempts that this retry policy will allow.
|
RecordSuccessResponse |
recordSuccess(RecordSuccessRequest request)
Invoked after an attempt succeeds.
|
RefreshRetryTokenResponse |
refreshRetryToken(RefreshRetryTokenRequest request)
Invoked before each subsequent (non-first) request attempt.
|
RetryStrategy.Builder<?,?> |
toBuilder()
Create a new
RetryStrategy.Builder with the current configuration. |
default boolean |
useClientDefaults()
Returns whether the retry strategy uses default retry predicates.
|
AcquireInitialTokenResponse acquireInitialToken(AcquireInitialTokenRequest request)
Callers MUST wait for the delay returned by this call before making the first attempt. Callers that wish to
retry a failed attempt MUST call refreshRetryToken(com.ibm.cos.v2.retries.api.RefreshRetryTokenRequest) before doing so.
If the attempt was successful, callers MUST call recordSuccess(com.ibm.cos.v2.retries.api.RecordSuccessRequest).
NullPointerException - if a required parameter is not specifiedTokenAcquisitionFailedException - if a token cannot be acquiredRefreshRetryTokenResponse refreshRetryToken(RefreshRetryTokenRequest request)
Callers MUST wait for the delay returned by this call before making the next attempt. If the next attempt
fails, callers MUST re-call refreshRetryToken(com.ibm.cos.v2.retries.api.RefreshRetryTokenRequest) before attempting another retry. This call invalidates the provided
token, and returns a new one. Callers MUST use the new token.
If the attempt was successful, callers MUST call recordSuccess(com.ibm.cos.v2.retries.api.RecordSuccessRequest).
NullPointerException - if a required parameter is not specifiedIllegalArgumentException - if the provided token was not issued by this strategy or the provided token was
already used for a previous refresh or success call.TokenAcquisitionFailedException - if a token cannot be acquiredRecordSuccessResponse recordSuccess(RecordSuccessRequest request)
NullPointerException - if a required parameter is not specifiedIllegalArgumentException - if the provided token was not issued by this strategy or the provided token was already
used for a previous refresh or success call.int maxAttempts()
default boolean useClientDefaults()
RetryStrategy.Builder<?,?> toBuilder()
RetryStrategy.Builder with the current configuration.
This is useful for modifying the strategy's behavior, like conditions or max retries.
Copyright © 2026. All rights reserved.