RFR: 8304065: HttpServer.stop should terminate immediately if no exchanges are in progress [v2]

Mikhail Yankelevich myankelevich at openjdk.org
Wed May 21 16:40:43 UTC 2025


On Tue, 20 May 2025 17:20:26 GMT, Daniel Jeliński <djelinski at openjdk.org> wrote:

>> src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java line 252:
>> 
>>> 250:         selector.wakeup();
>>> 251:         long latest = System.nanoTime() + delay * 1000000000L;
>>> 252:         while (System.nanoTime() < latest) {
>> 
>> This is not correct as `latest` may overflow.
>> 
>> Suggestion:
>> 
>>         long start = System.nanoTime();
>>         while ((System.nanoTime() - start) / 1000_000L < delay ) {
>
> I suppose you could also replace `finished` with a CountDownLatch and get rid of the ugly `delay()` in a loop.

Changed to the countdownlatch, so is removed in the next commit

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25333#discussion_r2100724645


More information about the net-dev mailing list