test/jdk/java/net/CookieHandler/CookieManagerTest.java
changeset 55399 46049b8a5658
parent 51724 8abb0fa2c334
child 58108 5302477c8285
--- a/test/jdk/java/net/CookieHandler/CookieManagerTest.java	Mon Jun 17 15:31:49 2019 +0800
+++ b/test/jdk/java/net/CookieHandler/CookieManagerTest.java	Mon Jun 17 20:03:34 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, 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
@@ -57,8 +57,9 @@
         } catch (IOException x) {
             System.out.println("Debug: caught:" + x);
         }
-        System.out.println("Using: \"127.0.0.1\"");
-        return "127.0.0.1";
+        InetAddress loopback = InetAddress.getLoopbackAddress();
+        System.out.println("Using: \"" + loopback.getHostAddress() + "\"");
+        return loopback.getHostAddress();
     }
 
     public static void main(String[] args) throws Exception {
@@ -73,7 +74,7 @@
 
    public static void startHttpServer() throws IOException {
         httpTrans = new CookieTransactionHandler();
-        server = HttpServer.create(new InetSocketAddress(0), 0);
+        server = HttpServer.create(new InetSocketAddress(hostAddress, 0), 0);
         server.createContext("/", httpTrans);
         server.start();
     }