test/jdk/java/net/URLClassLoader/closetest/CloseTest.java
changeset 54314 46cf212cdcca
parent 51977 a8862960c19f
child 57686 70f5cbb711a9
--- a/test/jdk/java/net/URLClassLoader/closetest/CloseTest.java	Wed Mar 27 13:00:57 2019 -0700
+++ b/test/jdk/java/net/URLClassLoader/closetest/CloseTest.java	Wed Mar 27 09:06:43 2019 -0700
@@ -42,6 +42,7 @@
 import java.io.IOException;
 import java.lang.reflect.Method;
 import java.net.URLClassLoader;
+import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.URL;
 import java.nio.file.Files;
@@ -49,6 +50,7 @@
 import java.nio.file.Paths;
 
 import jdk.test.lib.compiler.CompilerUtils;
+import jdk.test.lib.net.URIBuilder;
 import jdk.test.lib.util.JarUtils;
 
 import com.sun.net.httpserver.HttpContext;
@@ -157,8 +159,12 @@
 
     static URL getServerURL() throws Exception {
         int port = httpServer.getAddress().getPort();
-        String s = "http://127.0.0.1:" + port + "/";
-        return new URL(s);
+        return URIBuilder.newBuilder()
+            .scheme("http")
+            .loopback()
+            .port(port)
+            .path("/")
+            .toURL();
     }
 
     static void startHttpServer(String docroot) throws Exception {