-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8294193: Files.createDirectories throws FileAlreadyExistsException for a symbolic link whose target is an existing directory #10383
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
👋 Welcome back jpai! A progress list of the required criteria for merging this PR into |
Webrevs
|
|
It passed on our machine with this patch. |
|
I think create a new issue for Files.createDirectories issue or else move the existing issue from hotspot/runtime and change the description. I plan to review this change but not today because it require digging into some security issues. For the test then I think it will mean moving the existing tests from Misc.java to the new source file. That will fit with the description that you propose for the new test. |
|
Hello Alan,
I've now created a separate JBS and this PR has been updated to link to that JBS.
I've updated the PR to move the
Please take your time. |
| // create one directory | ||
| Path subdir = tmpdir.resolve("a"); | ||
| Files.createDirectories(subdir); | ||
| assertTrue(Files.exists(subdir), subdir + " was expected to exist, but didn't"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realise this is moved from Misc.java but if you replace the "exists" with "isDirectory" then it improve the testing.
| throw new SkipException("Symbolic links not supported"); | ||
| } | ||
| System.out.println("Running tests under directory " + startingDir.toAbsolutePath()); | ||
| final Path fooDir = Files.createDirectory(Path.of(startingDir.toString(), "foo")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can simplify this to Files.createDirectory(top.resolve("foo")), same for barDir, and symlink.
|
|
||
| /** | ||
| * Creates a symlink which points to a directory that exists. Then calls Files.createDirectories | ||
| * method passing it the path to the symlink and verifies that no exception gets thrown |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can simplify the wording with something like "Test Files.createDirectories symbolic file with an existing directory."
| @Test | ||
| public void testSymlinkDir() throws Exception { | ||
| // create a temp dir as the "root" in which we will run our tests. | ||
| final Path startingDir = Files.createTempDirectory(Path.of("."), "8293792"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests in this area use TestUtil.createTemporaryDirectory() so it's probably best to keep it consistent if you can.
Also can you rename "startingDir" to "top" as that will make the test much easier to read.
|
Hello Alan, I've updated the PR to implement your suggestions in the test. The test continues to pass. |
AlanBateman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates and for taking this issue.
|
@jaikiran This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be: You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 47 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
|
Thank you for the review, Alan. |
|
/integrate |
|
Going to push as commit 169a5d4.
Your commit was automatically rebased without conflicts. |
Can I please get a review of this change which proposes to fix the issue noted in https://bugs.openjdk.org/browse/JDK-8294193?
As discussed in a related PR #10266 (comment), this is a genuine bug in the
java.nio.file.Files.createDirectoriesimplementation. The commit in this PR fixes that by making sure that links are followed when checking if aPathis a directory during the creation of directories in thecreateDirectoriesimplementation. Theprivatemethod which is changed in this PR is only used in theFiles.createDirectoriesand no other place, so this change should not impact any other code. Additionally a new test has been added to reproduce the issue and verify the fix.tier1, tier2 and tier3 tests passed with this change.
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/10383/head:pull/10383$ git checkout pull/10383Update a local copy of the PR:
$ git checkout pull/10383$ git pull https://git.openjdk.org/jdk pull/10383/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 10383View PR using the GUI difftool:
$ git pr show -t 10383Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/10383.diff