RFR: 8256461: AbstractFileSystemProvider.getSunPathForSocketCall for empty Path returns '.'
Michael McMahon
michaelm at openjdk.java.net
Tue Nov 17 15:06:06 UTC 2020
On Tue, 17 Nov 2020 14:36:14 GMT, Daniel Fuchs <dfuchs 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.
>
> src/java.base/windows/classes/sun/nio/fs/WindowsFileSystemProvider.java line 635:
>
>> 633: }
>> 634: String s = file.toString();
>> 635: return s.getBytes(StandardCharsets.UTF_8);
>
> I'd suggest to refactor:
>
> WindowsPath file = WindowsPath.toWindowsPath(obj);
> String s = file.toString();
> return s.isEmpty() ? emptyPath : s.getBytes(StandardCharsets.UTF_8);
Good idea. Thanks!
-------------
PR: https://git.openjdk.java.net/jdk/pull/1258
More information about the nio-dev
mailing list