Integrated: 8357539: TimeSource.now() is not monotonic

Daniel Jeliński djelinski at openjdk.org
Fri May 23 11:58:05 UTC 2025


On Thu, 22 May 2025 09:53:26 GMT, Daniel Jeliński <djelinski at openjdk.org> wrote:

> We observed a case where the instants returned by `TimeSource.now()` were returned in non-monotonic order. The reason was that sometimes we were using a delay calculated with one `localSource` as an input to a different (updated on another thread) `localSource`. This was confirmed by putting `assert firstNanos + delay == nanos;` under `instant(long, long)`.
> 
> The fix ensures that we won't accidentally use the incorrect delay by removing the `instant(long, long)` overload, and calculating the delay in the method where it is used.
> 
> No new test; instrumenting this class for testing would likely double its size. Tier2 tests continue to pass.

This pull request has now been integrated.

Changeset: 488e4ea5
Author:    Daniel Jeliński <djelinski at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/488e4ea5c6bc47be1d777bf5c26e2ffa2c436e28
Stats:     11 lines in 1 file changed: 5 ins; 2 del; 4 mod

8357539: TimeSource.now() is not monotonic

Reviewed-by: dfuchs, jpai

-------------

PR: https://git.openjdk.org/jdk/pull/25390


More information about the net-dev mailing list