RFR: 8349812: Unexpected exception opening empty path name with WRITE, CREATE_NEW

Alan Bateman alanb at openjdk.org
Tue Feb 11 11:01:10 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 seems to be an oversight from when this code was introduced in JDK 7. 

We use a convention in this area for the title on JBS issues so I've had to rename the JBS issue. Can you rename the PR to align with this. We will likely need to add a lot more tests to ensure that all methods/options are exercised with an empty Path.

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

PR Comment: https://git.openjdk.org/jdk/pull/23560#issuecomment-2650461762


More information about the nio-dev mailing list