From a07b72bfcfa603453ea042e89adeb9dcec8bf63a Mon Sep 17 00:00:00 2001 From: Daniel Fuchs Date: Fri, 22 Nov 2024 09:55:07 +0000 Subject: [PATCH] 8344346: java/net/httpclient/ShutdownNow.java fails with java.lang.AssertionError: client was still running, but exited after further delay: timeout should be adjusted Reviewed-by: jpai --- test/jdk/java/net/httpclient/ShutdownNow.java | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/test/jdk/java/net/httpclient/ShutdownNow.java b/test/jdk/java/net/httpclient/ShutdownNow.java index 47eb1f6d7c9..d175840724d 100644 --- a/test/jdk/java/net/httpclient/ShutdownNow.java +++ b/test/jdk/java/net/httpclient/ShutdownNow.java @@ -30,6 +30,7 @@ * isTerminated. * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.httpclient.test.lib.http2.Http2TestServer jdk.test.lib.net.SimpleSSLContext + * jdk.test.lib.RandomFactory jdk.test.lib.Utils * ReferenceTracker * @run testng/othervm * -Djdk.internal.httpclient.debug=true @@ -41,8 +42,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.net.InetAddress; -import java.net.InetSocketAddress; import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpClient.Redirect; @@ -58,20 +57,12 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionException; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.RejectedExecutionException; -import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; import jdk.httpclient.test.lib.common.HttpServerAdapters; -import jdk.httpclient.test.lib.http2.Http2TestServer; import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLHandshakeException; -import com.sun.net.httpserver.HttpServer; -import com.sun.net.httpserver.HttpsConfigurator; -import com.sun.net.httpserver.HttpsServer; import jdk.test.lib.RandomFactory; +import jdk.test.lib.Utils; import jdk.test.lib.net.SimpleSSLContext; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeTest; @@ -211,7 +202,7 @@ public class ShutdownNow implements HttpServerAdapters { } CompletableFuture.allOf(responses.toArray(new CompletableFuture[0])).get(); } finally { - if (client.awaitTermination(Duration.ofMillis(2500))) { + if (client.awaitTermination(Duration.ofMillis(Utils.adjustTimeout(1000)))) { out.println("Client terminated within expected delay"); assertTrue(client.isTerminated()); } else { @@ -277,7 +268,7 @@ public class ShutdownNow implements HttpServerAdapters { }).thenCompose((c) -> c).get(); } } finally { - if (client.awaitTermination(Duration.ofMillis(2500))) { + if (client.awaitTermination(Duration.ofMillis(Utils.adjustTimeout(1000)))) { out.println("Client terminated within expected delay"); assertTrue(client.isTerminated()); } else {