Skip to content

Commit 9c6505f

Browse files
authored
Merge pull request ReactiveX#11 from charithe/master
Fix to allow retry durations over 10 ms
2 parents 38225cc + 6bf914c commit 9c6505f

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/main/java/javaslang/retry/RetryContext.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ public Builder maxAttempts(int maxAttempts) {
9393
}
9494

9595
public Builder waitDuration(Duration waitDuration) {
96-
if (waitDuration.getSeconds() < 0.01) {
97-
throw new IllegalArgumentException("waitDurationInOpenState must be at least than 10[ms]");
96+
if (waitDuration.toMillis() < 10) {
97+
throw new IllegalArgumentException("waitDurationInOpenState must be at least 10ms");
9898
}
9999
this.waitDuration = waitDuration;
100100
return this;

src/test/java/javaslang/retry/RetryBuilderTest.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
import java.time.Duration;
2424

25+
import static org.assertj.core.api.Assertions.assertThat;
26+
2527
public class RetryBuilderTest {
2628

2729
@Test(expected = IllegalArgumentException.class)
@@ -33,4 +35,21 @@ public void zeroMaxAttemptsShouldFail() {
3335
public void zeroWaitIntervalShouldFail() {
3436
Retry.custom().waitDuration(Duration.ofMillis(0)).build();
3537
}
38+
39+
@Test(expected = IllegalArgumentException.class)
40+
public void WaitIntervalUnderTenMillisShouldFail() {
41+
Retry.custom().waitDuration(Duration.ofMillis(5)).build();
42+
}
43+
44+
@Test
45+
public void waitIntervalOfTenMillisShouldSucceed() {
46+
Retry retryCtx = Retry.custom().waitDuration(Duration.ofMillis(10)).build();
47+
assertThat(retryCtx).isNotNull();
48+
}
49+
50+
@Test
51+
public void waitIntervalOverTenMillisShouldSucceed() {
52+
Retry retryCtx = Retry.custom().waitDuration(Duration.ofSeconds(10)).build();
53+
assertThat(retryCtx).isNotNull();
54+
}
3655
}

0 commit comments

Comments
 (0)