dragonwell-project / dragonwell8

Alibaba Dragonwell8 JDK
http://dragonwell-jdk.io
GNU General Public License v2.0
4.21k stars 497 forks source link

【自研】[TESTBUG]com/alibaba/wisp/io/DatagramSocketTest.java使用固定端口 #520

Open sendaoYan opened 1 year ago

sendaoYan commented 1 year ago
diff --git a/jdk/test/com/alibaba/wisp/io/DatagramSocketTest.java b/jdk/test/com/alibaba/wisp/io/DatagramSocketTest.java
index 8d58480f92..59286021c8 100644
--- a/jdk/test/com/alibaba/wisp/io/DatagramSocketTest.java
+++ b/jdk/test/com/alibaba/wisp/io/DatagramSocketTest.java
@@ -64,7 +64,10 @@ public class DatagramSocketTest {
     static public void testSendAndReceive() throws Exception {
         CountDownLatch count = new CountDownLatch(1);
         InetAddress host = InetAddress.getByName("localhost");
-        int port = 9527;
+        int port = 0;
+        ServerSocket ss = new ServerSocket(port);
+        System.out.println("port get from os = " + port);
+        port = ss.getLocalPort();
         DatagramSocket so = new DatagramSocket(port);
         so.setSoTimeout(1_000);
         final int loop = 1024;

patch.diff.log