Closed timothybasanov closed 2 years ago
@timothybasanov Which version did you hit this with? I'm having trouble reproducing on 2.4.4 and 3.1. Does it reproduce for you on 3.1?
Not a Contribution.
Verified that it is present in 2.4.1 and was fixed in 2.4.2 already. Thank you!
When a circuit breaker is already open and
runAsync
is used,ExecutionContext.getElapsedTime()
returns unexpectedly large numbers (e.g. days instead of seconds) within an event listener.Seemingly the issue is caused by not starting an execution in rare edge cases. As a default start timestamp is 0 nanos, it means that elapsed time may be measured since a random point in time (e.g. since the last laptop restart) instead of an expected value.
It also may make sense to switch from
Duration
tolong
orInstant
withinExecutionContext
to more accurately reflect that it is a point in time. Additionally, using a default value ofSystem.nanoTime()
orInstant.now()
may decrease a risk of an incorrect initialization.Reproducing an issue
When run on my laptop it shows a duration of several days and not seconds:
Workaround
Check if the execution has not started and return a predefined constant e.g.