test/jdk/java/net/Socket/NullHost.java
changeset 57686 70f5cbb711a9
parent 47216 71c04702a3d5
child 58108 5302477c8285
--- a/test/jdk/java/net/Socket/NullHost.java	Thu Aug 08 18:44:11 2019 +0100
+++ b/test/jdk/java/net/Socket/NullHost.java	Thu Aug 08 21:58:11 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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
@@ -36,7 +36,10 @@
 
         public Server() throws IOException {
             svr = new ServerSocket();
-            svr.bind(new InetSocketAddress(0));
+            // The client side calls Socket((String) null, ...) which
+            // resolves to InetAddress.getByName((String)null) which in
+            // turns will resolve to the loopback address
+            svr.bind(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0));
         }
 
         public int getPort() {