Skip to content

Methods with timeout should not crash on negative time #310

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
elizarov opened this issue Apr 3, 2018 · 1 comment
Closed

Methods with timeout should not crash on negative time #310

elizarov opened this issue Apr 3, 2018 · 1 comment
Assignees

Comments

@elizarov
Copy link
Contributor

elizarov commented Apr 3, 2018

Methods like delay, withTimeout, onTimeout all require(time >= 0). This leads to error-prone time-based code. See gist for #306 for example: https://gist.github.com/elizarov/34150213209158d0dce0db62d9c0a20f

This code in this gist happens to work if this line is removed, but it would still wrong without this this line (it will subtly main sometimes):

if (remainingNanos <= 0) break // this window is over

We should remove require(time >= 0) from all time-based methods. They should assume that they should not delay (or assume imediate timeout) when negative time is passed.

@qwwdfsad
Copy link
Member

qwwdfsad commented Apr 10, 2018

CompletableFuture immediately throws TimeoutException if a timeout is not positive.
Rx, Rx2, and Reactor throw TimeoutException if a timeout is not positive, though timeout task is properly scheduled. Negative delay treated as no delay everywhere, but with Delay task scheduling

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants