Skip to content

Conversation

@bplb
Copy link
Member

@bplb bplb commented Oct 29, 2025

If getFinalPath throws an exception, or converts a drive path to a UNC path, then fall back to the slow path which uses resolveAllLinks.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8368165: (fs) Path.toRealPath does not perform correctly for symbolic links in a mapped drive (win) (Bug - P4)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/28032/head:pull/28032
$ git checkout pull/28032

Update a local copy of the PR:
$ git checkout pull/28032
$ git pull https://git.openjdk.org/jdk.git pull/28032/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 28032

View PR using the GUI difftool:
$ git pr show -t 28032

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/28032.diff

Using Webrev

Link to Webrev Comment

@bplb
Copy link
Member Author

bplb commented Oct 29, 2025

This change was tested successfully with links and files on a local mapped disk and on remote shares on macOS and Windows machines.

It might be that falling back to the slow path should be limited to a certain subset of error codes encountered by GetFinalPathNameByHandle rather than falling back for all exceptions.

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 29, 2025

👋 Welcome back bpb! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Oct 29, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk
Copy link

openjdk bot commented Oct 29, 2025

@bplb The following label will be automatically applied to this pull request:

  • nio

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the rfr Pull request is ready for review label Oct 29, 2025
@mlbridge
Copy link

mlbridge bot commented Oct 29, 2025

Webrevs

@AlanBateman
Copy link
Contributor

toRealPath is specified to throw if it fails. The error FileSystemException: Z:\link: The name of the file cannot be resolved by the system seems okay. So I'm not yet convinced we need to change anything.

@bplb
Copy link
Member Author

bplb commented Oct 29, 2025

I don't think the current behavior is incorrect, but it does not provide the sought for outcome. The fallback path using resolveAllLinks appears to find the desired answer in these cases where GetFinalPathNameByHandle itself fails.

@AlanBateman
Copy link
Contributor

I don't think the current behavior is incorrect, but it does not provide the sought for outcome. The fallback path using resolveAllLinks appears to find the desired answer in these cases where GetFinalPathNameByHandle itself fails.

We can't fallback unconditionally when GetFinalPathNameByHandle fails. The only reason for this fallback path is for cases where there is a sym link to something that we know doesn't support links. So this is why it is limited to ERROR_INVALID_LEVEL, and even then it is dubious and maybe we need to explore the errors and interop issues further before seeing if anything should be done.

@bplb
Copy link
Member Author

bplb commented Oct 30, 2025

We can't fallback unconditionally when GetFinalPathNameByHandle fails.

Right, I was uncertain about this which is why I commented above that "It might be that falling back to the slow path should be limited to a certain subset of error codes".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

nio [email protected] rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

2 participants