RFR 8144672: (ch) PipeImpl should use localhost instead of loopback address

Brian Burkhalter brian.burkhalter at oracle.com
Wed Feb 14 00:09:24 UTC 2018


https://bugs.openjdk.java.net/browse/JDK-8144672

Replace the hard-coded IPv4 loopback address:

--- a/src/java.base/windows/classes/sun/nio/ch/PipeImpl.java
+++ b/src/java.base/windows/classes/sun/nio/ch/PipeImpl.java
@@ -110,7 +110,7 @@
                     ByteBuffer bb = ByteBuffer.allocate(NUM_SECRET_BYTES);
 
                     // Loopback address
-                    InetAddress lb = InetAddress.getByName("127.0.0.1");
+                    InetAddress lb = InetAddress.getLoopbackAddress();
                     assert(lb.isLoopbackAddress());

Or would it be better to replace getLoopbackAddress() in the above with getLocalHost()? Doing the latter may impose a security manager check.

Thanks,

Brian


More information about the nio-dev mailing list