--- a/test/jdk/com/sun/net/httpserver/Test12.java Mon Jun 10 10:11:42 2019 +0100
+++ b/test/jdk/com/sun/net/httpserver/Test12.java Tue Jun 11 15:46:26 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -27,6 +27,7 @@
* @library /test/lib
* @build jdk.test.lib.net.SimpleSSLContext
* @run main/othervm Test12
+ * @run main/othervm -Djava.net.preferIPv6Addresses=true Test12
* @summary Light weight HTTP server
*/
@@ -37,6 +38,7 @@
import java.net.*;
import javax.net.ssl.*;
import jdk.test.lib.net.SimpleSSLContext;
+import jdk.test.lib.net.URIBuilder;
/* basic http/s connectivity test
* Tests:
@@ -56,7 +58,8 @@
try {
String root = System.getProperty ("test.src")+ "/docs";
System.out.print ("Test12: ");
- InetSocketAddress addr = new InetSocketAddress (0);
+ InetAddress loopback = InetAddress.getLoopbackAddress();
+ InetSocketAddress addr = new InetSocketAddress(loopback, 0);
s1 = HttpServer.create (addr, 0);
s2 = HttpsServer.create (addr, 0);
HttpHandler h = new FileServerHandler (root);
@@ -130,8 +133,13 @@
public void run () {
try {
- URL url = new URL (protocol+"://localhost:"+port+"/test1/"+f);
- HttpURLConnection urlc = (HttpURLConnection) url.openConnection();
+ URL url = URIBuilder.newBuilder()
+ .scheme(protocol)
+ .loopback()
+ .port(port)
+ .path("/test1/"+f)
+ .toURL();
+ HttpURLConnection urlc = (HttpURLConnection) url.openConnection(Proxy.NO_PROXY);
if (urlc instanceof HttpsURLConnection) {
HttpsURLConnection urlcs = (HttpsURLConnection) urlc;
urlcs.setHostnameVerifier (new HostnameVerifier () {