On Thu, 22 May 2025 18:56:29 GMT, Daniel Jeliński <djelin...@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.
>
> Daniel Jeliński has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   Restore instant(long,long)

src/java.net.http/share/classes/jdk/internal/net/http/common/TimeSource.java 
line 100:

> 98:         long nanos = System.nanoTime();
> 99:         long delay = source.delay(nanos);
> 100:         // use localSource if possible to avoid a volatile read

Hello Daniel, the changes look OK to me. However, this pre-existing comment is 
now misplaced.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25390#discussion_r2103819574

Reply via email to