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

Mark Sheppard msheppar at openjdk.org
Fri May 23 08:57:55 UTC 2025


On Thu, 22 May 2025 12:27:46 GMT, Mikhail Yankelevich <myankelevich at 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.
>
> Mikhail Yankelevich has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Suggestions from cr
>   
>   Co-authored-by: Daniel Fuchs <67001856+dfuch at users.noreply.github.com>

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

> 239:      */
> 240:     public void stop (int delay) {
> 241:         if (delay < 0) {

with the use of CountDownLatch the negative check becomes superfluous i.e.

public boolean await(long timeout, TimeUnit unit) throws InterruptedException
Causes the current thread to wait until the latch has counted down to zero, unless the thread is interrupted, or the specified waiting time elapses.

. . . 
If the specified waiting time elapses then the value false is returned. If the time is less than or equal to zero, the method will not wait at all.

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

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


More information about the net-dev mailing list