RFR: 8368625: com/sun/net/httpserver/ServerStopTerminationTest.java fails intermittently in tier7

Mikhail Yankelevich myankelevich at openjdk.org
Fri Oct 10 12:50:43 UTC 2025


On Tue, 7 Oct 2025 15:50:30 GMT, Mark Sheppard <msheppar at openjdk.org> wrote:

>> I believe that increasing the timeout might help, as it seems to be happening due to the machine load. I'm going to make a pr increasing the timeout to 20 from 5 (similar to what it was when timeout factor was 4).
>
> The extending of the stop duration may not have the desired effect of eliminating what appears to be a race condition in the test
> 
> One of the recorded failures is  for the temporal condition
> 
>         // The shutdown should take at least as long as the exchange duration
>         if (elapsed < exchangeDuration.toNanos()) {
>             fail("HttpServer.stop terminated before exchange completed");
>         }
> 
> This is a somewhat dubious constraint and can’t always be met
> 
> The test assumes that the participating threads are all actively executing simultaneously, which may not be true
> They may be scheduled to run rather than actually running.
> 
> Restating the objective of the test
> Objective: to ensure that the stop request is not processed while there are extant exchanges 
> 
> Potential race scenario:
> 
> Server started creates exchange which waits for a signal to complete
> 
> Exchange completion thread starts waits for 1 seconds before it can signal exchange to compete — the complete signal will be thus invoked sometime after 1 second depending on OS thread scheduling
> 
> Main thread continues and invokes a stop which has a max wait time of 5 seconds  for extant exchanges to complete — so max completion time of stop is 5 seconds ++ i.e. could be slightly longer than 5 seconds again subject to OS scheduling
> 
> Temporal condition imposed by test
> 
>         // The shutdown should take at least as long as the exchange duration
>         if (elapsed < exchangeDuration.toNanos()) {
>             fail("HttpServer.stop terminated before exchange completed");
>         }
> 
>         // The delay should not have expired
>         if (elapsed >= delayDuration.toNanos()) { 
>             fail("HttpServer.stop terminated after delay expired");
>         }
> 
> 1. States elapsed time of stop should be less than the duration of the exchange exchangeDuration. BUT exchangeDuration is not the
> duration of the exchange completion. Rather, it is the time delay before the exchange thread is signalled to complete. 
> The actual completion of the exchange may be sometime later, again depending on OS thread scheduling.
> 
> Second condition is that the elapsed time of the stop should be less than or equal to the stop delay. BUT if the full timeout for the 
> stop expires as per
> 
> server.stop will wait a max of N (5) seconds before terminating as per
> 
>         try {
>             // waiting for the duration of the delay, unless released before
>             finishedLatch.await(delay, TimeUnit.SECONDS);
> 
>         } catch (InterruptedExceptio...

@msheppar @dfuch thanks for the review! I believe it should be fixed in the latest commit

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

PR Comment: https://git.openjdk.org/jdk/pull/27670#issuecomment-3389904485


More information about the net-dev mailing list