Integrated: 8349812: (fs) Files.newByteChannel with empty path name and CREATE_NEW throws unexpected exception

Maxim Kartashev mkartashev at openjdk.org
Fri Feb 14 15:32:14 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.

This pull request has now been integrated.

Changeset: 0414dcec
Author:    Maxim Kartashev <mkartashev at openjdk.org>
Committer: Brian Burkhalter <bpb at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/0414dcec118fce24037ca1a6b00561c0ce4c6953
Stats:     28 lines in 2 files changed: 24 ins; 0 del; 4 mod

8349812: (fs) Files.newByteChannel with empty path name and CREATE_NEW throws unexpected exception

Reviewed-by: bpb

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

PR: https://git.openjdk.org/jdk/pull/23560


More information about the nio-dev mailing list