On Tue, 17 Nov 2026 15:30:55 GMT, Volkan Yazici <[email protected]> wrote:

>> Switch `jdk.httpserver` from wall clock to a monotonic one. This effectively 
>> fixes elapsed time measurements and scheduled event fire instants. Bonus: 
>> improves the test stability.
>> 
>> In short, replaced the `System.currentTimeMillis()` & `java.util.Timer` 
>> combination with the `System.nanoTime()` & `ScheduledExecutorService` 
>> alternative.
>> 
>> ---------
>> - [X] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Volkan Yazici has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Fix `long` overflow in `monotonicInstantMillis`

src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java line 165:

> 163:                 IDLE_TIMER_TASK_SCHEDULE, IDLE_TIMER_TASK_SCHEDULE, 
> TimeUnit.MILLISECONDS);
> 164:         if (reqRspTimeoutEnabled) {
> 165:             scheduler.scheduleAtFixedRate(

Suggestion:

            scheduler.scheduleWithFixedDelay(

src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java line 1250:

> 1248:      */
> 1249:     private static long monotonicInstantMillis() {
> 1250:         return TimeUnit.NANOSECONDS.toMillis(START_INSTANT_NANOS - 
> System.nanoTime());

Suggestion:

        return TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - 
START_INSTANT_NANOS);

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

PR Review Comment: https://git.openjdk.org/jdk/pull/33890#discussion_r4602173150
PR Review Comment: https://git.openjdk.org/jdk/pull/33890#discussion_r4602141801

Reply via email to