RFR: 8349812: (fs) Files.newByteChannel with empty path name and CREATE_NEW throws unexpected exception [v3]
Brian Burkhalter
bpb at openjdk.org
Wed Feb 12 21:54:27 UTC 2025
On Wed, 12 Feb 2025 10:13:27 GMT, Maxim Kartashev <mkartashev at openjdk.org> wrote:
>> `UnixFileChannelFactory.open()` checks for the current directory by looking at the first byte of the name, which in case of an empty path is simply not there. This check throws an `ArrayIndexOutOfBoundsException` and prevents the correct exception from being thrown.
>>
>> The suggested solution is to use another method that translates a path name into a byte array called `getByteArrayForSysCalls()` that is specifically designed to handle the case of empty path names.
>>
>> Tested by running `java/nio` tests on Linux.
>
> Maxim Kartashev has updated the pull request incrementally with one additional commit since the last revision:
>
> Extended the test for empty path name
test/jdk/java/nio/file/Files/SBC.java line 444:
> 442: } catch (FileSystemException x) { }
> 443:
> 444: try (var channel = Files.newByteChannel(Path.of(""), READ, LinkOption.NOFOLLOW_LINKS)) {
This sub-test fails on Windows with a `java.nio.file.AccessDeniedException`.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/23560#discussion_r1953452170
More information about the nio-dev
mailing list