On Tue, 20 May 2025 16:24:30 GMT, Daniel Fuchs <dfu...@openjdk.org> wrote:
>> HttpServer::stop will terminate the server immidiately after all exhcnages >> are complete. >> If the exchanges take longer then the specified delay it will terminate >> straight after the delay, the same as the previous behaviour. >> >> Used to wait until the delay is complete at all times, regardless of the >> number of active exchanges. >> >> Tests based on @eirbjo work, so adding Eirik as a contributor. > > 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. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/25333#discussion_r2098500452