test/jdk/sun/net/www/protocol/http/6550798/test.java
changeset 54314 46cf212cdcca
parent 47216 71c04702a3d5
child 54787 7748aa47b4e2
--- a/test/jdk/sun/net/www/protocol/http/6550798/test.java	Wed Mar 27 13:00:57 2019 -0700
+++ b/test/jdk/sun/net/www/protocol/http/6550798/test.java	Wed Mar 27 09:06:43 2019 -0700
@@ -24,6 +24,7 @@
 /**
  * @test
  * @bug 6550798
+ * @library /test/lib
  * @summary Using InputStream.skip with ResponseCache will cause partial data to be cached
  * @modules jdk.httpserver
  * @run main/othervm test
@@ -33,6 +34,8 @@
 import com.sun.net.httpserver.*;
 import java.io.*;
 
+import jdk.test.lib.net.URIBuilder;
+
 public class test {
 
     final static int LEN = 16 * 1024;
@@ -58,7 +61,13 @@
         s.start();
 
         System.out.println("http request with cache hander");
-        URL u = new URL("http://127.0.0.1:"+s.getAddress().getPort()+"/f");
+        URL u = URIBuilder.newBuilder()
+            .scheme("http")
+            .loopback()
+            .port(s.getAddress().getPort())
+            .path("/f")
+            .toURL();
+        System.out.println("URL: " + u);
         URLConnection conn = u.openConnection();
 
         InputStream is = null;