On Tue, 8 Oct 2024 19:50:54 GMT, Roger Riggs <[email protected]> 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.
>
> test/jdk/java/time/tck/java/time/TCKInstant.java line 193:
> 
>> 191:         Instant test = Instant.now();
>> 192:         long diff = Math.abs(test.toEpochMilli() - 
>> expected.toEpochMilli());
>> 193:         assertTrue(diff < 10_000);  // less than 10 secs
> 
> Given arbitrary delays between the two executions; the premise of the test 
> itself is suspect; especially if the allowed time is increased.  I think the 
> test is supposed to be testing that the default clock for Instant.now() is 
> the SystemUTC clock.
> I'd expect expected to be less than or equal to test.
> The use of math.abs allows the clock to go backwards; that might happen if 
> the time was re-set manually.

Thanks @RogerRiggs for the comments. I increased the diff allowance to absorb 
any compilation related delays. What would you propose here?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/21413#discussion_r1792666022

Reply via email to