RFR: 8315273: (fs) Path.toRealPath(LinkOption.NOFOLLOW_LINKS) fails when "../../" follows a link (win) [v5]

Daniel Jeliński djelinski at openjdk.org
Wed Sep 11 11:23:15 UTC 2024


On Fri, 1 Mar 2024 21:48:22 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

>> Windows implementation of integrated pull request #15397. The test java/nio/file/Path/ToRealPath.java is also removed from the problem list.
>
> Brian Burkhalter has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains seven commits:
> 
>  - 8315273: Re-remove ToRealPath test
>  - Merge
>  - 8315273: Revert ProblemList
>  - Merge
>  - Merge
>  - 8315273: Add bug ID to test
>  - 8315273: (fs) Path.toRealPath(LinkOption.NOFOLLOW_LINKS) fails when "../../" follows a link (win)

I don't think we want to do this.
On Windows, symbolic links to directories are almost identical to directories: you can have a symbolic link on the path to the working directory, and entering and exiting a symbolic link takes you back to the directory you were originally in. This behavior is observed in many Windows applications. If we change the handling of `..` in paths containing symlinks, Java's interpretation of these paths will be inconsistent with other applications.

I think we should relax the ToRealPath test; instead of making assumptions on what toRealPath should return, the test could verify that a file created using a path containing `symlink....\file` can be opened using the path returned by toRealPath. As long as toRealPath points to the same file, the exact path shouldn't matter.

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

PR Comment: https://git.openjdk.org/jdk/pull/15525#issuecomment-2343358526


More information about the nio-dev mailing list