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

Maxim Kartashev mkartashev at openjdk.org
Tue Feb 11 10:33:19 UTC 2025


`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.

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

Commit messages:
 - 8349812: Unexpected exception opening empty path name with WRITE, CREATE_NEW

Changes: https://git.openjdk.org/jdk/pull/23560/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=23560&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8349812
  Stats: 10 lines in 2 files changed: 9 ins; 0 del; 1 mod
  Patch: https://git.openjdk.org/jdk/pull/23560.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/23560/head:pull/23560

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


More information about the nio-dev mailing list