@@ -206,7 +206,7 @@ public void cappedExponentialDelays() {
206
206
final Delay cappedExponential = CappedExponential .of ().timeout (Duration .ofMinutes (20 )).maxDelay (MAX_DELAY ).powerBy (1.3 )
207
207
.minDelay (Duration .ofSeconds (1 )).build ();
208
208
int [] results = { 1 , 1 , 2 , 2 , 3 , 4 , 5 , 6 , 8 , 11 , 14 , 15 , 15 , 15 , 15 , 15 , 15 };
209
- for (int tries = 0 ; tries <= 15 ; tries ++) {
209
+ for (int tries = 1 ; tries <= 15 ; tries ++) {
210
210
Duration delay = cappedExponential .nextDelay (tries );
211
211
assertThat (results [tries ]).isEqualTo ((int ) delay .getSeconds ());
212
212
if (tries >= 11 ) {
@@ -218,7 +218,7 @@ public void cappedExponentialDelays() {
218
218
final Delay cappedExponentialNoPower = CappedExponential .of ().timeout (Duration .ofMinutes (20 )).maxDelay (MAX_DELAY )
219
219
.minDelay (Duration .ofSeconds (2 )).build ();
220
220
int [] resultsNoPower = { 2 , 2 , 4 , 8 , 15 , 15 , 15 , 15 , 15 };
221
- for (int tries = 0 ; tries <= 6 ; tries ++) {
221
+ for (int tries = 1 ; tries <= 6 ; tries ++) {
222
222
Duration delay = cappedExponentialNoPower .nextDelay (tries );
223
223
assertThat (resultsNoPower [tries ]).isEqualTo ((int ) delay .getSeconds ());
224
224
if (tries >= 5 ) {
@@ -230,20 +230,20 @@ public void cappedExponentialDelays() {
230
230
final Delay cappedExponentialTimeout = CappedExponential .of ().timeout (Duration .ofSeconds (5 ))
231
231
.maxDelay (Duration .ofSeconds (1 )).powerBy (1.0 ).minDelay (Duration .ofSeconds (1 )).build ();
232
232
233
- int [] resultsTimeout = { 1 , 1 , 1 , 1 , 1 , 0 };
234
- for (int tries = 0 ; tries <= 5 ; tries ++) {
233
+ int [] resultsTimeout = { 1 , 1 , 1 , 1 , 1 , 1 , 0 };
234
+ for (int tries = 1 ; tries <= 6 ; tries ++) {
235
235
Duration delay = cappedExponentialTimeout .nextDelay (tries );
236
236
assertThat (resultsTimeout [tries ]).isEqualTo ((int ) delay .getSeconds ());
237
- if (tries >= 5 ) {
237
+ if (tries >= 6 ) {
238
238
assertThat (0 ).isEqualTo (delay .getSeconds ());
239
239
}
240
240
}
241
241
242
242
// If minDelay is not passed, it's set to default 1.
243
243
final Delay cappedExponentialNoMinDelay = CappedExponential .of ().timeout (Duration .ofSeconds (5 ))
244
244
.maxDelay (Duration .ofSeconds (1 )).powerBy (1.0 ).build ();
245
- int [] resultsNoMinDelay = { 1 , 1 , 1 , 1 , 1 , 0 };
246
- for (int tries = 0 ; tries <= 5 ; tries ++) {
245
+ int [] resultsNoMinDelay = { 1 , 1 , 1 , 1 , 1 , 1 , 0 };
246
+ for (int tries = 1 ; tries <= 5 ; tries ++) {
247
247
Duration delay = cappedExponentialNoMinDelay .nextDelay (tries );
248
248
assertThat (resultsNoMinDelay [tries ]).isEqualTo ((int ) delay .getSeconds ());
249
249
}
@@ -252,18 +252,18 @@ public void cappedExponentialDelays() {
252
252
final Delay cappedExponentialNoMaxDelay = CappedExponential .of ().timeout (Duration .ofMinutes (20 ))
253
253
.minDelay (Duration .ofSeconds (2 )).build ();
254
254
int [] resultsNoMaxDelay = { 2 , 2 , 4 , 8 , 16 , 20 , 20 , 20 , 20 };
255
- for (int tries = 0 ; tries <= 6 ; tries ++) {
255
+ for (int tries = 1 ; tries <= 6 ; tries ++) {
256
256
Duration delay = cappedExponentialNoMaxDelay .nextDelay (tries );
257
257
assertThat (resultsNoMaxDelay [tries ]).isEqualTo ((int ) delay .getSeconds ());
258
258
}
259
259
260
260
final Delay cappedExponentialSameMinMaxDelay = CappedExponential .of ().timeout (Duration .ofSeconds (5 ))
261
261
.maxDelay (Duration .ofSeconds (1 )).powerBy (1.3 ).minDelay (Duration .ofSeconds (1 )).build ();
262
- int [] resultsSameMinMaxDelay = { 1 , 1 , 1 , 1 , 1 , 0 };
263
- for (int tries = 0 ; tries <= 5 ; tries ++) {
262
+ int [] resultsSameMinMaxDelay = { 1 , 1 , 1 , 1 , 1 , 1 , 0 };
263
+ for (int tries = 1 ; tries <= 6 ; tries ++) {
264
264
Duration delay = cappedExponentialSameMinMaxDelay .nextDelay (tries );
265
265
assertThat (resultsSameMinMaxDelay [tries ]).isEqualTo ((int ) delay .getSeconds ());
266
- if (tries >= 5 ) {
266
+ if (tries >= 6 ) {
267
267
assertThat (0 ).isEqualTo (delay .getSeconds ());
268
268
}
269
269
}
0 commit comments