RFR: 8154364: (fs) Files.isSameFile() throws NoSuchFileException with broken symbolic links [v3]
Alan Bateman
alanb at openjdk.org
Tue Aug 19 10:45:40 UTC 2025
On Thu, 14 Aug 2025 16:16:17 GMT, Alan Bateman <alanb at openjdk.org> wrote:
>> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
>>
>> 8154364: Propagate change of previous commit to Windows
>
> src/java.base/unix/classes/sun/nio/fs/UnixFileSystemProvider.java line 430:
>
>> 428: // neither exist and comparison of normalized paths is problematic,
>> 429: // so return false
>> 430: return false;
>
> I think you can drop "comparison of normalized paths is problematic" as it begs too many questions for anyone looking at this code.
If lastKey is changed to throw when a last file key cannot be obtained then it would simplify the file access in isSameFile to:
UnixFileKey key1;
try {
UnixFileAttributes attrs = UnixFileAttributes.getIfExists(file1);
key1 = (attrs != null) ? attrs.fileKey() : lastFileKey(file1);
} catch (UnixException e) {
e.rethrowAsIOException(file1);
return false;
}
UnixFileKey key2;
try {
UnixFileAttributes attrs = UnixFileAttributes.getIfExists(file2);
key2 = (attrs != null) ? attrs.fileKey() : lastFileKey(file2);
} catch (UnixException e) {
e.rethrowAsIOException(file2);
return false;
}
return key1.equals(key2);
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26736#discussion_r2284856554
More information about the nio-dev
mailing list