RFR: 8365626: (fs) Improve handling of broken links in Files.isSameFile() (win)

Brian Burkhalter bpb at openjdk.org
Fri Sep 5 15:42:11 UTC 2025


On Fri, 5 Sep 2025 13:19:26 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> Improve handling of broken symbolic links in `Files.isSameFile` on Windows as was done on Unix by the fix of [JDK-8154364](https://bugs.openjdk.org/browse/JDK-8154364).
>
> src/java.base/windows/classes/sun/nio/fs/WindowsFileSystemProvider.java line 424:
> 
>> 422:     // contains file attributes and its handle
>> 423:     // the attributes' key is valid as long as the handle remains open
>> 424:     private record AttrsAndHandle(WindowsFileAttributes attrs, long handle) {}
> 
> "the handle remains open" is important. If I read the change correctly then the handle is closed at each step, thus invalidating (in the sense that the file key may be recycled) the entries in the set. I think the closes will need to be done in bulk, in a finally block.

Unless I got it wrong, the handles remain open only until they are no longer needed, i.e., after comparison of the volume serial numbers and file indices.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27079#discussion_r2325428716


More information about the nio-dev mailing list