@@ -206,7 +206,7 @@ public void cappedExponentialDelays() {
206206 final Delay cappedExponential = CappedExponential .of ().timeout (Duration .ofMinutes (20 )).maxDelay (MAX_DELAY ).powerBy (1.3 )
207207 .minDelay (Duration .ofSeconds (1 )).build ();
208208 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 ++) {
210210 Duration delay = cappedExponential .nextDelay (tries );
211211 assertThat (results [tries ]).isEqualTo ((int ) delay .getSeconds ());
212212 if (tries >= 11 ) {
@@ -218,7 +218,7 @@ public void cappedExponentialDelays() {
218218 final Delay cappedExponentialNoPower = CappedExponential .of ().timeout (Duration .ofMinutes (20 )).maxDelay (MAX_DELAY )
219219 .minDelay (Duration .ofSeconds (2 )).build ();
220220 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 ++) {
222222 Duration delay = cappedExponentialNoPower .nextDelay (tries );
223223 assertThat (resultsNoPower [tries ]).isEqualTo ((int ) delay .getSeconds ());
224224 if (tries >= 5 ) {
@@ -230,20 +230,20 @@ public void cappedExponentialDelays() {
230230 final Delay cappedExponentialTimeout = CappedExponential .of ().timeout (Duration .ofSeconds (5 ))
231231 .maxDelay (Duration .ofSeconds (1 )).powerBy (1.0 ).minDelay (Duration .ofSeconds (1 )).build ();
232232
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 ++) {
235235 Duration delay = cappedExponentialTimeout .nextDelay (tries );
236236 assertThat (resultsTimeout [tries ]).isEqualTo ((int ) delay .getSeconds ());
237- if (tries >= 5 ) {
237+ if (tries >= 6 ) {
238238 assertThat (0 ).isEqualTo (delay .getSeconds ());
239239 }
240240 }
241241
242242 // If minDelay is not passed, it's set to default 1.
243243 final Delay cappedExponentialNoMinDelay = CappedExponential .of ().timeout (Duration .ofSeconds (5 ))
244244 .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 ++) {
247247 Duration delay = cappedExponentialNoMinDelay .nextDelay (tries );
248248 assertThat (resultsNoMinDelay [tries ]).isEqualTo ((int ) delay .getSeconds ());
249249 }
@@ -252,18 +252,18 @@ public void cappedExponentialDelays() {
252252 final Delay cappedExponentialNoMaxDelay = CappedExponential .of ().timeout (Duration .ofMinutes (20 ))
253253 .minDelay (Duration .ofSeconds (2 )).build ();
254254 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 ++) {
256256 Duration delay = cappedExponentialNoMaxDelay .nextDelay (tries );
257257 assertThat (resultsNoMaxDelay [tries ]).isEqualTo ((int ) delay .getSeconds ());
258258 }
259259
260260 final Delay cappedExponentialSameMinMaxDelay = CappedExponential .of ().timeout (Duration .ofSeconds (5 ))
261261 .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 ++) {
264264 Duration delay = cappedExponentialSameMinMaxDelay .nextDelay (tries );
265265 assertThat (resultsSameMinMaxDelay [tries ]).isEqualTo ((int ) delay .getSeconds ());
266- if (tries >= 5 ) {
266+ if (tries >= 6 ) {
267267 assertThat (0 ).isEqualTo (delay .getSeconds ());
268268 }
269269 }
0 commit comments