From 11007a14ccc913cc55a738160c4525dae6f9de17 Mon Sep 17 00:00:00 2001 From: michaelm Date: Wed, 11 Apr 2018 10:19:37 +0100 Subject: [PATCH] 8196775: java/net/Socket/asyncClose/Race.java failed intermittently on Windows with ConnectException: Connection refused Reviewed-by: dfuchs --- test/java/net/Socket/asyncClose/Race.java | 57 ++++++++++++----------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/test/java/net/Socket/asyncClose/Race.java b/test/java/net/Socket/asyncClose/Race.java index 5a9585682..3a7b7affe 100644 --- a/test/java/net/Socket/asyncClose/Race.java +++ b/test/java/net/Socket/asyncClose/Race.java @@ -30,6 +30,7 @@ import java.io.InputStream; import java.net.ServerSocket; import java.net.Socket; +import java.net.ConnectException; import java.net.SocketException; import java.util.concurrent.Phaser; @@ -43,33 +44,37 @@ public class Race { final int port = ss.getLocalPort(); final Phaser phaser = new Phaser(THREADS + 1); for (int i=0; i<100; i++) { - final Socket s = new Socket("localhost", port); - s.setSoLinger(false, 0); - try (Socket sa = ss.accept()) { - sa.setSoLinger(false, 0); - final InputStream is = s.getInputStream(); - Thread[] threads = new Thread[THREADS]; - for (int j=0; j