@@ -61,6 +61,11 @@ public interface RetryStrategy {
6161 /**
6262 * Invoked before the first request attempt.
6363 *
64+ * <p >An initial request will be made even if a token cannot be acquired.
65+ * It is recommended to always return a token so that the retry strategy
66+ * may continue to track each request and be informed when they succeed or
67+ * fail.
68+ *
6469 * @throws TokenAcquisitionFailedException if a token cannot be acquired.
6570 */
6671 RetryToken acquireInitialToken ();
@@ -99,7 +104,9 @@ to prevent race conditions.
99104
100105An initial retry token should be acquired at the beginning of a request, before
101106the first attempt is made. If an initial token cannot be acquired, the client
102- should still make an attempt.
107+ should still make an attempt. This initial attempt is always made because the
108+ purpose of the retry strategy is to manage retries, not to gate access to a
109+ service entirely.
103110
104111If an attempt fails, the retry strategy is passed the retry token for the
105112attempt and given the exception raised by the attempt. If the retry strategy
@@ -407,7 +414,7 @@ demonstrate some of the potential needs of a retry system.
407414
408415The following is an example retry strategy that implements exponential backoff
409416with jitter alongside a token bucket. This strategy adds extra cost for timeout
410- errors since they may indicate a more highly degraded service.
417+ errors since they may indicate a more degraded service.
411418
412419Aside from delay, the retry token also tracks the number of attempts that have
413420been made. This is necessary because this strategy imposes a maximum attempt
@@ -557,7 +564,7 @@ public final class AwsStandardRetryStrategy implements RetryStrategy {
557564 synchronized (tokensLock) {
558565 // When a successful request is made, refill the token bucket unless it
559566 // is already at maximum capacity.
560- if (this . tokens < MAX_CAPACITY ) {
567+ if (this . tokens <= MAX_CAPACITY - SUCCESS_REFUND ) {
561568 this . tokens += SUCCESS_REFUND ;
562569 }
563570 }
0 commit comments