@@ -203,13 +203,9 @@ public void exponentialDelays() {
203
203
@ Test
204
204
public void cappedExponentialDelays () {
205
205
Duration MAX_DELAY = Duration .ofSeconds (15 );
206
- final Delay cappedExponential = CappedExponential .of ()
207
- .timeout (Duration .ofMinutes (20 ))
208
- .maxDelay (MAX_DELAY )
209
- .powerBy (1.3 )
210
- .minDelay (Duration .ofSeconds (1 ))
211
- .build ();
212
- int [] results = {1 , 1 , 1 , 1 , 2 , 2 , 3 , 4 , 6 , 8 , 10 , 13 , 15 , 15 , 15 , 15 };
206
+ final Delay cappedExponential = CappedExponential .of ().timeout (Duration .ofMinutes (20 )).maxDelay (MAX_DELAY ).powerBy (1.3 )
207
+ .minDelay (Duration .ofSeconds (1 )).build ();
208
+ int [] results = { 1 , 1 , 1 , 1 , 2 , 2 , 3 , 4 , 6 , 8 , 10 , 13 , 15 , 15 , 15 , 15 };
213
209
for (int tries = 0 ; tries <= 15 ; tries ++) {
214
210
Duration delay = cappedExponential .nextDelay (tries );
215
211
assertThat (results [tries ]).isEqualTo ((int ) delay .getSeconds ());
@@ -218,7 +214,7 @@ public void cappedExponentialDelays() {
218
214
}
219
215
}
220
216
221
- //If minDelay is not set, the retry is without delay.
217
+ // If minDelay is not set, the retry is without delay.
222
218
final Delay cappedExponentialNoDelay = CappedExponential .of ().timeout (Duration .ofSeconds (12 )).build ();
223
219
for (int tries = 0 ; tries <= 15 ; tries ++) {
224
220
Duration delay = cappedExponentialNoDelay .nextDelay (tries );
@@ -228,14 +224,11 @@ public void cappedExponentialDelays() {
228
224
}
229
225
}
230
226
231
- //If powerBy is not passed, it's set to default 2.
232
- final Delay cappedExponentialNoPower = CappedExponential .of ()
233
- .timeout (Duration .ofMinutes (20 ))
234
- .maxDelay (MAX_DELAY )
235
- .minDelay (Duration .ofSeconds (1 ))
236
- .build ();
227
+ // If powerBy is not passed, it's set to default 2.
228
+ final Delay cappedExponentialNoPower = CappedExponential .of ().timeout (Duration .ofMinutes (20 )).maxDelay (MAX_DELAY )
229
+ .minDelay (Duration .ofSeconds (1 )).build ();
237
230
238
- int [] resultsNoPower = {1 , 1 , 2 , 4 , 8 , 15 , 15 , 15 , 15 , 15 };
231
+ int [] resultsNoPower = { 1 , 1 , 2 , 4 , 8 , 15 , 15 , 15 , 15 , 15 };
239
232
for (int tries = 0 ; tries <= 6 ; tries ++) {
240
233
Duration delay = cappedExponentialNoPower .nextDelay (tries );
241
234
assertThat (resultsNoPower [tries ]).isEqualTo ((int ) delay .getSeconds ());
0 commit comments