Closed timothybasanov closed 3 years ago
It's been a while on this issue, apologies. I tried reproducing your scenario against 2.4.0 and I couldn't exactly working as you described, though clearly with a single thread Timeouts don't fire as expected. Here's the test case I added based on your description: https://github.com/failsafe-lib/failsafe/blob/master/src/test/java/net/jodah/failsafe/issues/Issue260Test.java
This issue is now resolved in master. Let me know if the test case looks off or if I missed something.
Reproduction:
FailsafeExecutor
that hasRetryPolicy
andTimeout
getAsync
) where each is slightly faster than the timeoutExecution order (with timeout of 10s and task length 9s):
00s
all three executions are scheduled00s
first task starts execution, others are in the queue09s
first task finishes the execution09s
second task starts execution10s
second task is interrupted due to timeout10s
third task is interrupted due to timeout10s
second task attempt 2 starts execution19s
second task succeedsAs far as I can see if the future returned from
net.jodah.failsafe.Functions#getPromiseAsync
cancelled before its execution starts thensupplier
is never called andpromise
is never completed.This is somewhat similar to #257, but does not require thread pool and its queue to overflow. This may require a special scheduler (e.g. recommended in that issue that executes
timeoutFuture
directly on theScheduledExecutorPool
.) With default scheduler timeouts do not start until the actual task execution starts, so there are no timeouts for all three tasks.Reproducible on 2.4.0.