--- a/test/jdk/sun/net/www/protocol/http/UserAuth.java Thu Aug 15 15:39:43 2019 +0800
+++ b/test/jdk/sun/net/www/protocol/http/UserAuth.java Thu Aug 15 12:58:27 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -81,7 +81,19 @@
* Http Server
*/
void startHttpServer() throws IOException {
- httpServer = com.sun.net.httpserver.HttpServer.create(new InetSocketAddress(0), 0);
+ InetAddress address = InetAddress.getLocalHost();
+ if (!InetAddress.getByName(address.getHostName()).equals(address)) {
+ // if this happens then we should possibly change the client
+ // side to use the address literal in its URL instead of
+ // the host name.
+ throw new IOException(address.getHostName()
+ + " resolves to "
+ + InetAddress.getByName(address.getHostName())
+ + " not to "
+ + address + ": check host configuration.");
+ }
+
+ httpServer = com.sun.net.httpserver.HttpServer.create(new InetSocketAddress(address, 0), 0);
// create HttpServer context
HttpContext ctx = httpServer.createContext("/redirect/", new RedirectHandler());