RFR: 8356678: (fs) Files.readAttributes should map ENOTDIR to NoSuchFileException where possible (unix)

Alan Bateman alanb at openjdk.org
Tue May 13 06:23:51 UTC 2025


On Mon, 12 May 2025 19:36:22 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

> Treat `ENOTDIR` as causing a `NoSuchFileException` instead of a `FileSystemExcception` in some places in order to handle cases such as a regular file named, for example, `foo/bar`.

test/jdk/java/nio/file/Files/NotADirectory.java line 69:

> 67:         try {
> 68:             Files.copy(leaf, Path.of("junk"));
> 69:         } catch (NoSuchFileException expected) {

FYI you can use assertThrows to avoid the try-catch.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25191#discussion_r2086006015


More information about the nio-dev mailing list