RFR: 8374441: FileSystemProvider.readAttributesIfExists should return null for ENOTDIR (unix)

Alan Bateman alanb at openjdk.org
Fri Jan 2 07:09:51 UTC 2026


On Wed, 31 Dec 2025 21:14:29 GMT, Fabian Meumertzheim <fmeum at openjdk.org> wrote:

> `FileSystemProvider.readAttributesIfExists` now returns `null` for a path with a true prefix that is not a directory rather than throwing `NotDirectoryException`.

FileSystemProvider.readAttributesIfExists is part of the SPI so should be rare to see a direct usage. Instead, the usages are indirect, e.g. Files.isXXX to avoid using exceptions for control flow. Would it be possible to update the JBS issue or this PR with a some context as to how you ran into this. The implementation of APIs such as Files.isXXX will already handle the FileSystemException so the change should be transparent. I'm wondering if we've missed something in another usage (of some API) that causes the FileSystemException to surface.

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

PR Comment: https://git.openjdk.org/jdk/pull/29013#issuecomment-3704640027


More information about the nio-dev mailing list