From 7ace98c16dadf62fb8a366a2ca4f7397b25de30b Mon Sep 17 00:00:00 2001 From: Mikhail Yankelevich Date: Tue, 7 Oct 2025 11:10:13 +0100 Subject: [PATCH 1/3] JDK-8368625: com/sun/net/httpserver/ServerStopTerminationTest.java fails intermittently in tier7 --- test/jdk/com/sun/net/httpserver/ServerStopTerminationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/jdk/com/sun/net/httpserver/ServerStopTerminationTest.java b/test/jdk/com/sun/net/httpserver/ServerStopTerminationTest.java index 8156116072585..7839d4226ea87 100644 --- a/test/jdk/com/sun/net/httpserver/ServerStopTerminationTest.java +++ b/test/jdk/com/sun/net/httpserver/ServerStopTerminationTest.java @@ -128,7 +128,7 @@ public void shouldAwaitActiveExchange() throws InterruptedException { log("Complete Exchange triggered"); // Time the shutdown sequence - final Duration delayDuration = Duration.ofSeconds(Utils.adjustTimeout(5)); + final Duration delayDuration = Duration.ofSeconds(Utils.adjustTimeout(20)); log("Shutdown triggered with the delay of " + delayDuration.getSeconds()); final long elapsed = timeShutdown(delayDuration); log("Shutdown complete"); From 6272c59bdfbdd02b7d8a7c368b0ba813e24cc6a0 Mon Sep 17 00:00:00 2001 From: Mikhail Yankelevich Date: Fri, 10 Oct 2025 11:04:35 +0100 Subject: [PATCH 2/3] race condition fix --- .../sun/net/httpserver/ServerStopTerminationTest.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/jdk/com/sun/net/httpserver/ServerStopTerminationTest.java b/test/jdk/com/sun/net/httpserver/ServerStopTerminationTest.java index 7839d4226ea87..78e8a313997a5 100644 --- a/test/jdk/com/sun/net/httpserver/ServerStopTerminationTest.java +++ b/test/jdk/com/sun/net/httpserver/ServerStopTerminationTest.java @@ -161,6 +161,7 @@ public void shouldCompeteAfterDelay() throws InterruptedException { // Complete the exchange 10 second into the future. // Runs in parallel, so won't block the server stop final Duration exchangeDuration = Duration.ofSeconds(Utils.adjustTimeout(10)); + final long startTime = System.nanoTime(); // taking custom start time just in case completeExchange(exchangeDuration); log("Complete Exchange triggered"); @@ -168,7 +169,7 @@ public void shouldCompeteAfterDelay() throws InterruptedException { // Time the shutdown sequence final Duration delayDuration = Duration.ofSeconds(1); log("Shutdown triggered with the delay of " + delayDuration.getSeconds()); - final long elapsed = timeShutdown(delayDuration); + final long elapsed = timeShutdown(delayDuration, startTime); log("Shutdown complete"); @@ -277,7 +278,14 @@ public void shouldAllowRepeatedStop() { */ private long timeShutdown(Duration delayDuration) { final long startTime = System.nanoTime(); + return timeShutdown(delayDuration, startTime); + } + /** + * This allows passing a custom start time + */ + private long timeShutdown(Duration delayDuration, + long startTime) { server.stop((int) delayDuration.toSeconds()); return System.nanoTime() - startTime; } From d272f9613c2c439cd47d89954410cd0a6cf1eccf Mon Sep 17 00:00:00 2001 From: Mikhail Yankelevich Date: Fri, 10 Oct 2025 13:45:03 +0100 Subject: [PATCH 3/3] race condition fix --- test/jdk/com/sun/net/httpserver/ServerStopTerminationTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/jdk/com/sun/net/httpserver/ServerStopTerminationTest.java b/test/jdk/com/sun/net/httpserver/ServerStopTerminationTest.java index 78e8a313997a5..408290ca8a15a 100644 --- a/test/jdk/com/sun/net/httpserver/ServerStopTerminationTest.java +++ b/test/jdk/com/sun/net/httpserver/ServerStopTerminationTest.java @@ -124,13 +124,14 @@ public void shouldAwaitActiveExchange() throws InterruptedException { // Complete the exchange one second into the future final Duration exchangeDuration = Duration.ofSeconds(1); + final long startTime = System.nanoTime(); // taking custom start time just in case completeExchange(exchangeDuration); log("Complete Exchange triggered"); // Time the shutdown sequence final Duration delayDuration = Duration.ofSeconds(Utils.adjustTimeout(20)); log("Shutdown triggered with the delay of " + delayDuration.getSeconds()); - final long elapsed = timeShutdown(delayDuration); + final long elapsed = timeShutdown(delayDuration, startTime); log("Shutdown complete"); // The shutdown should take at least as long as the exchange duration