RFR: 8256461: AbstractFileSystemProvider.getSunPathForSocketCall for empty Path returns '.' [v2]

Alan Bateman alanb at openjdk.java.net
Tue Nov 17 18:02:13 UTC 2020


On Tue, 17 Nov 2020 15:52:20 GMT, Michael McMahon <michaelm at openjdk.org> wrote:

>> Could I get the following change reviewed please? 
>> 
>> The problem results from AbstractFileSystemProvider.getSunPathForSocketCall  returning a path of '.' when given an empty path argument. The socket API needs an empty path byte[] in this situation. It causes a BindException which is actually correct, but the error message is confusing because "." always exists and the error message is saying 'path already exists' when the actual error is that server socket channels cannot be bound to the empty path.
>> 
>> Thanks,
>> Michael.
>
> Michael McMahon has updated the pull request incrementally with one additional commit since the last revision:
> 
>   update after Alan and Daniel's comments Tues 17th

src/java.base/share/classes/sun/nio/fs/AbstractFileSystemProvider.java line 161:

> 159:      * Returns a path name as bytes for a Unix domain socket.
> 160:      * Different encodings may be used for these names on some platforms.
> 161:      * If file is empty, then an empty byte[] is returned.

This should be mis-read as "empty file" when you mean "empty path".

src/java.base/windows/classes/sun/nio/fs/WindowsFileSystemProvider.java line 50:

> 48: {
> 49:     private static final Unsafe unsafe = Unsafe.getUnsafe();
> 50:     private static final byte[] emptyPath = new byte[0];

Is "unsafe" used, maybe this could be removed while you are there.
Probably should be EMPTY_PATH to be consistent with the name in UnixFileSystemProvider.

-------------

PR: https://git.openjdk.java.net/jdk/pull/1258


More information about the nio-dev mailing list