RFR: 8368625: com/sun/net/httpserver/ServerStopTerminationTest.java fails intermittently [v2]

Daniel Fuchs dfuchs at openjdk.org
Tue Oct 21 13:16:32 UTC 2025


On Tue, 21 Oct 2025 09:27:02 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:

>> apologies I got my cut and paste all wrong
>> 
>> shouldAwaitActiveExchange
>
> All clear then! :-)

Continuing the thread here although it belongs to other test:

> The second temporal constraint is something that could possibly fail. If it fails why is it considered a test failure?


        if (elapsed >= delayDuration.toNanos()) {
            fail("HttpServer.stop terminated after delay expired");
        }


You are absolutely right - this can fail. We're taking a x20 margin though - so I would expect the occurrences should be very infrequent (if ever). That is - the server should be able to stop after the exchange complete - and the exchange is configured to complete after 1s - while the server stop waits for at most 20s. If more than 20s elapse between the time we take the startTime snapshot, and the time the server exits from stop, then the test will fail. This could happen - if for instance you do Thread.sleep(20) before calling `timeShutdown`. So this check is not reliable. However - it should be unlikely.

I will import this PR and do some more testing. I am tempted to suggest that we should still fail in this case, but possibly change the message:


-             fail("HttpServer.stop terminated after delay expired");
+             // this comparison is not 100% reliable and could fail if the main thread
+             // was premempted for long enough. We could raise `delayDuration` again 
+             // to make it less likely.
+             fail("HttpServer.stop terminated after delay expired. Consider raising `delayDuration` to avoid intermittent failures");

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27670#discussion_r2448216584


More information about the net-dev mailing list