test/jdk/java/net/Socket/ProxyCons.java
changeset 57686 70f5cbb711a9
parent 54811 9db7c0f561a6
--- a/test/jdk/java/net/Socket/ProxyCons.java	Thu Aug 08 18:44:11 2019 +0100
+++ b/test/jdk/java/net/Socket/ProxyCons.java	Thu Aug 08 21:58:11 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -64,12 +64,14 @@
     }
 
     void test() throws Exception {
-        ServerSocket ss = new ServerSocket(0);
+        InetAddress localHost = InetAddress.getLocalHost();
+        ServerSocket ss = new ServerSocket();
+        ss.bind(new InetSocketAddress(localHost, 0));
         try {
             Server s = new Server(ss);
             s.start();
             Socket sock = new Socket(Proxy.NO_PROXY);
-            sock.connect(new InetSocketAddress("localhost", ss.getLocalPort()));
+            sock.connect(new InetSocketAddress(localHost, ss.getLocalPort()));
             s.done();
             sock.close();
         } catch (java.io.IOException e) {