RFR: 8349812: (fs) Files.newByteChannel with empty path name and CREATE_NEW throws unexpected exception
Jaikiran Pai
jpai at openjdk.org
Tue Feb 11 12:11:15 UTC 2025
On Tue, 11 Feb 2025 10:28:58 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.
test/jdk/java/nio/file/Files/SBC.java line 66:
> 64: unsupportedOptions(dir);
> 65: nullTests(dir);
> 66: emptyPathTest();
I think the `@bug` of this test would also have to be updated to include `8349812`.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/23560#discussion_r1950728147
More information about the nio-dev
mailing list