vert.x icon indicating copy to clipboard operation
vert.x copied to clipboard

setTimer should not throw when delay < 1

Open alamothe opened this issue 4 years ago • 1 comments

Version

4.1.2

Context

When setTimer is called with delay <1, it will throw IllegalArgumentException.

This behavior is unacceptable as it can easily take down the whole service.

Instead, it simply needs to do max(delay, 1).

Note that node.js doesn't throw in this case. There is no sane argument why it should throw. setTimer(0) simply means execute as soon as possible.

alamothe avatar Sep 02 '21 10:09 alamothe

If you need to schedule a task for execution asap, you can use io.vertx.core.Vertx#runOnContext.

If you're willing to provide a PR we may consider it.

tsegismont avatar Sep 09 '21 14:09 tsegismont