File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed
main/java/net/jodah/failsafe
test/java/net/jodah/failsafe Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ class RetryPolicyExecutor extends PolicyExecutor<RetryPolicy> {
3737 private volatile int failedAttempts ;
3838 private volatile boolean retriesExceeded ;
3939 /** The fixed, backoff, random or computed delay time in nanoseconds. */
40- private volatile long delayNanos = - 1 ;
40+ private volatile long delayNanos ;
4141
4242 // Listeners
4343 private final EventListener abortListener ;
@@ -221,7 +221,7 @@ private long getFixedOrRandomDelayNanos(long waitNanos) {
221221 Duration delayMin = policy .getDelayMin ();
222222 Duration delayMax = policy .getDelayMax ();
223223
224- if (waitNanos == - 1 && delay != null && !delay .equals (Duration .ZERO ))
224+ if (waitNanos == 0 && delay != null && !delay .equals (Duration .ZERO ))
225225 waitNanos = delay .toNanos ();
226226 else if (delayMin != null && delayMax != null )
227227 waitNanos = randomDelayInRange (delayMin .toNanos (), delayMax .toNanos (), Math .random ());
Original file line number Diff line number Diff line change @@ -539,6 +539,20 @@ public void shouldSkipExecutionWhenCircuitOpen() {
539539 assertThrows (future ::get , ExecutionException .class , CircuitBreakerOpenException .class );
540540 }
541541
542+ public void testRetryPolicyScheduledDelayIsZero () throws Throwable {
543+ RetryPolicy <Object > rp = new RetryPolicy <>().onRetryScheduled (e -> {
544+ assertEquals (e .getDelay ().toMillis (), 0 );
545+ System .out .println (e .getDelay ().toMillis ());
546+ waiter .resume ();
547+ });
548+
549+ Failsafe .with (rp ).runAsync (() -> {
550+ throw new IllegalStateException ();
551+ });
552+
553+ waiter .await (1000 );
554+ }
555+
542556 private void assertInterruptedExceptionOnCancel (FailsafeExecutor <Boolean > failsafe ) throws Throwable {
543557 CompletableFuture <Void > future = failsafe .runAsync (() -> {
544558 try {
You can’t perform that action at this time.
0 commit comments