changeset 8553:0c2c07d0864d

8077670: sun/security/krb5/auto/MaxRetries.java may fail with BindException Reviewed-by: chegar
author igerasim
date Fri, 30 Sep 2016 21:55:30 +0300
parents c27108976125
children 5c640dec49ef
files test/sun/security/krb5/auto/MaxRetries.java
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/test/sun/security/krb5/auto/MaxRetries.java	Fri Nov 24 05:00:54 2017 +0000
+++ b/test/sun/security/krb5/auto/MaxRetries.java	Fri Sep 30 21:55:30 2016 +0300
@@ -34,14 +34,18 @@
 import java.security.Security;
 
 public class MaxRetries {
+
+    static int idlePort = -1;
+
     public static void main(String[] args)
             throws Exception {
 
         System.setProperty("sun.security.krb5.debug", "true");
         new OneKDC(null).writeJAASConf();
 
-        // An idle UDP socket to revent PortUnreachableException
-        DatagramSocket ds = new DatagramSocket(33333);
+        // An idle UDP socket to prevent PortUnreachableException
+        DatagramSocket ds = new DatagramSocket();
+        idlePort = ds.getLocalPort();
 
         System.setProperty("java.security.krb5.conf", "alternative-krb5.conf");
 
@@ -200,7 +204,7 @@
                     fw.write("    kdc_timeout = " + BadKdc.toReal(value*1000) + "\n");
                 }
                 // Add a bad KDC as the first candidate
-                fw.write("    kdc = localhost:33333\n");
+                fw.write("    kdc = localhost:" + idlePort + "\n");
             }
             fw.write(s + "\n");
         }