failsafe: Considering allowing a Future result to be completed immediately when a Timeout occurs

Currently, Failsafe’s Timeout policy will wait until a user-provided supplier has completed before completing. This means that the Future that Failsafe returns to a user can’t be completed, even if a timeout is triggered, until the user’s supplier completes. This may not be desirable behavior.

That said, if a Timeout can return a completed promise before the user-provided supplier is complete, that means an outer RetryPolicy could trigger additional executions of the user-provided supplier while previous executions are still running, which in turn may time out and pile up. I believe this is to be expected for some use cases, but it’s an important behavioral change to consider.

Do we want Timeout to always wait for a supplier to complete before allowing outer policies to proceed, such as with retries? Should abandoning an execution at least be an option (timeout.withAbandon())? Thoughts welcome.

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Comments: 15 (8 by maintainers)

Most upvoted comments

Seems reasonable to me. “Abandon” is a good word for this, with the implication that the task (supplier) is left to its own devices. Might want to add a warning somewhere that repeated abandonment could lead to thread exhaustion.

Hi Jonathan,

I would be very happy to see an option for timeouts to return completed promises before the user-provided supplier completes. Actually, the fact that this is not the default behavior confused me quite a bit when I started using the library, which was not long ago.

My two cents!