RFR: 8324672: Update jdk/java/time/tck/java/time/TCKInstant.java now() to be more robust [v3]
Daniel Fuchs
dfuchs at openjdk.org
Tue Oct 15 13:12:11 UTC 2024
On Tue, 15 Oct 2024 12:31:52 GMT, Ramkumar Sunderbabu <rsunderbabu at openjdk.org> wrote:
>> The time difference check might fail for scenarios such as batch compilation. It is safer to give a bigger allowance of 10 seconds instead of 0.1 sec.
>>
>> Testing: The test was run for 100 times with -Xcomp option.
>
> Ramkumar Sunderbabu has updated the pull request incrementally with one additional commit since the last revision:
>
> checking if time is monotonic
test/jdk/java/time/tck/java/time/TCKInstant.java line 196:
> 194: instantMillis = Instant.now().toEpochMilli();
> 195: afterMillis = Instant.now(Clock.systemUTC()).toEpochMilli();
> 196: diff = instantMillis - beforeMillis;
Alternatively, you could set:
- `diff = afterMillis - beforeMillis;` (range should be < 100ms, instant is anyhwere inside) or,
- `diff = Math.abs(afterMillis / 2 - instantMillis + beforeMillis / 2);` (distance from instant to midpoint should be < 100ms)
Not that it matters much I guess - but it would give more symmetry... Feel free to ignore :-)
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/21413#discussion_r1801136453
More information about the core-libs-dev
mailing list