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

Alan Bateman alanb at openjdk.org
Thu Sep 18 18:39:18 UTC 2025


On Thu, 18 Sep 2025 17:47:43 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

>>> If `FileSystemLoopException` is thrown, then `h` could still be valid.
>> 
>> This is true but it will not have been added to the `linkAttrs` set and so should be closed, so that is correct.
>
> The variable `h` is set to a valid value by `openForReadAttributeAccess` and reset to invalid if `linkAttrs.add` succeeds. If `add` succeeds, then `h` is in a record added to `linkAttrs` and will be closed at line 507. If `add` fails, then `h` is not added to the set and is closed at line 502. I don't see how it can be closed twice.

Okay, I'll take another pass over this time. I think my main concern is that it has taken many iterations to get lastLinkAttributes right and it's still very fragile. One thing that would help is to add a linkAttributes methods that returns a EntryAttributes if a sym link or null if another file type. That would remove the need for "h" in lastLinkAttributes and remove some of the error paths in this method.

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

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


More information about the nio-dev mailing list