RFR: 8154364: (fs) Files.isSameFile() throws NoSuchFileException with broken symbolic links [v9]

Alan Bateman alanb at openjdk.org
Tue Aug 19 10:31:39 UTC 2025


On Mon, 18 Aug 2025 21:52:31 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

>> This request proposes to broaden the definition of which paths are considered to be the same by `java.nio.file.Files.isSameFile()`. A new test is added to cover many comparisons.
>
> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
> 
>   8154364: Improve Unix link handling; return false instead of throwing IOException on Windows

src/java.base/unix/classes/sun/nio/fs/UnixFileAttributes.java line 117:

> 115:         }
> 116: 
> 117:         return attrs;

We can create a follow-up issue to replace this with a version that doesn't use exceptions for control flow, like the 1-arg getIfExists. Then we can change the 1-arg method to use the 2-arg method.

src/java.base/unix/classes/sun/nio/fs/UnixFileSystemProvider.java line 393:

> 391:                 attrs2 = UnixFileAttributes.getIfExists(file2);
> 392:         } catch (UnixException x) {
> 393:             x.rethrowAsIOException(file1, file2);

I think it would be better to handle them separately as that will give a better exception if either fails. With the 2-arg rethrowAsIOException is mostly for move/copy ops.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26736#discussion_r2284822976
PR Review Comment: https://git.openjdk.org/jdk/pull/26736#discussion_r2284826790


More information about the nio-dev mailing list