unixdomainchannels: autobound local address problem unixdomainchannels
authormichaelm
Mon, 18 Nov 2019 16:53:41 +0000
branchunixdomainchannels
changeset 59123 ddb8977e44da
parent 59111 31b8ffbfe1b9
child 59208 ff7655b93101
unixdomainchannels: autobound local address problem
src/java.base/share/classes/sun/nio/ch/Net.java
src/java.base/share/classes/sun/nio/ch/UnixDomainSocketChannelImpl.java
--- a/src/java.base/share/classes/sun/nio/ch/Net.java	Fri Nov 15 16:30:39 2019 +0000
+++ b/src/java.base/share/classes/sun/nio/ch/Net.java	Mon Nov 18 16:53:41 2019 +0000
@@ -722,7 +722,7 @@
         return unixDomainSupported;
     }
 
-    private static UnixDomainSocketAddress UNNAMED = new UnixDomainSocketAddress("");
+    public static final UnixDomainSocketAddress UNNAMED = new UnixDomainSocketAddress("");
 
     static UnixDomainSocketAddress getRevealedLocalAddress(UnixDomainSocketAddress addr) {
         SecurityManager sm = System.getSecurityManager();
--- a/src/java.base/share/classes/sun/nio/ch/UnixDomainSocketChannelImpl.java	Fri Nov 15 16:30:39 2019 +0000
+++ b/src/java.base/share/classes/sun/nio/ch/UnixDomainSocketChannelImpl.java	Mon Nov 18 16:53:41 2019 +0000
@@ -173,7 +173,11 @@
                         throw new AlreadyBoundException();
                     UnixDomainSocketAddress usa = Net.checkUnixAddress(local);
                     Net.unixDomainBind(fd, usa);
-                    localAddress = Net.localUnixAddress(fd);
+                    if (usa == null) {
+                        localAddress = Net.UNNAMED;
+                    } else {
+                        localAddress = Net.localUnixAddress(fd);
+                    }
                 }
             } finally {
                 writeLock.unlock();