[crac] RFR: 8351402: [CRaC] Use System.nanoTime() in TimedWaitingTest

Anton Kozlov akozlov at openjdk.org
Fri Mar 7 13:45:09 UTC 2025


On Fri, 7 Mar 2025 12:15:50 GMT, Timofei Pushkin <tpushkin at openjdk.org> wrote:

> Replaces `System.currentTimeMillis()` with `System.nanoTime()` in `TimedWaitingTest` since the former can, in theory, jump back and forth and that may lead to the test failures.
> 
> Also adds a diagnostic assert.

A nit comment below, but I have a question on the approach in the bug.

test/jdk/jdk/crac/java/lang/System/TimedWaitingTest.java line 122:

> 120:             task.run();
> 121:             long after = System.nanoTime();
> 122:             if (after - before < WAIT_TIME_MILLIS) {

nanoTime reports time in nanoseconds, so this check is no longer valid.

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

PR Review: https://git.openjdk.org/crac/pull/209#pullrequestreview-2667266662
PR Review Comment: https://git.openjdk.org/crac/pull/209#discussion_r1985066779


More information about the crac-dev mailing list