On Tue, 18 May 2021 23:14:53 GMT, Stephen Colebourne <scolebou...@openjdk.org> 
wrote:

>> src/java.base/share/classes/java/time/Clock.java line 487:
>> 
>>> 485:             // it more unlikely to hit the 1ns in the future condition.
>>> 486:             localOffset = System.currentTimeMillis()/1000 - 1024;
>>> 487: 
>> 
>> Is it possible that after a fresh localOffset is retrieved, the thread is 
>> preempted and when it is scheduled again after a pause, the 
>> getNanoTimeAdjustment below returns -1 ? Would it help if instead of 
>> throwing exception, there was an infinite retry loop?
>
> This isn't my logic - it is existing code that has been moved. I'm not a fan 
> of infinite retry loops as the can hang the system. But I'm happy to change 
> it to work that way if there is a consensus to do so.

I see the localOffset passed to VM.getNanoTimeAdjustment() has to be in the 
range of current time +/- 2^32 seconds. This means the thread would have to 
sleep for ~136 years before the exception is triggered. I think this is more 
than enough. :-)

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

PR: https://git.openjdk.java.net/jdk/pull/4016

Reply via email to