-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8220816: (fs) Files.createDirectory should make it more obvious that it fails when the directory already exists #28378
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
base: master
Are you sure you want to change the base?
Conversation
…it fails when the directory already exists
|
👋 Welcome back bpb! A progress list of the required criteria for merging this PR into |
|
@bplb 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 57 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 |
Webrevs
|
justin-curtis-lu
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.
Wording looks reasonable to me. I presume the CSR will be filed after wording is finalized.
| * if the array contains an attribute that cannot be set atomically | ||
| * when creating the directory | ||
| * @throws FileAlreadyExistsException | ||
| * if a directory could not otherwise be created because a file of |
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.
Is it worth clarifying ..."file or directory"... in the throws tag as well?
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.
Is it worth clarifying ..."file or directory"... in the
throwstag as well?
Yes, I think so, thanks.
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.
Changed in commit 3af3490.
Yes. I generally wait for the discussion to converge before filing the CSR. |
|
Please note that this was discussed before on nio-dev. |
| * @throws FileAlreadyExistsException | ||
| * if a directory could not otherwise be created because a file of | ||
| * that name already exists <i>(optional specific exception)</i> | ||
| * if a directory could not otherwise be created because a file or |
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.
It is pre-existing wording, but I don't know that "otherwise" has any meaning here.
It reads the same whether "otherwise" is present or not.
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 don't know that "otherwise" has any meaning here.
No, I also don't think it does.
|
I think the Files.createFile has "Creates a new and empty file, failing if the file already exists", which I think is clear. It's less easy to create a sentence for createDirectory, createSymbolicFile and other methods. "Creates a directory, failing if the file already exists" is accurate but might not be clear to everyone that "file" means any file (sym link, directory, ...). I wonder if we could keep simple like this: "Creates a directory, failing if |
That's fine. I previously suggested
That might work. |
|
Commit 5c62cd5 does not (yet) address
|
| * @throws FileAlreadyExistsException | ||
| * if {@code dir} exists but is not a directory <i>(optional specific | ||
| * exception)</i> | ||
| * if {@code dir} locates an existing file but is not a directory |
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.
Maybe "that is not a directory" might be better.
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.
Fixed in 9cf6ede.
| /** | ||
| * Creates a new and empty file, failing if the file already exists. The | ||
| * Creates a new and empty file, failing if {@code path} locates an existing | ||
| * file. The |
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.
That works. I assume you'll re-flow this a bit to avoid "file. The" be on its own.
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 assume you'll re-flow this a bit
I left it that way intentionally to ease comparing the diffs in progress.
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.
Fixed in 9cf6ede.
| /** | ||
| * Creates a new link (directory entry) for an existing file <i>(optional | ||
| * Creates a new link (directory entry) for an existing file, | ||
| * failing if {@code link} locates an existing file <i>(optional |
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.
Minor nit, I think the comment has got mis-aligned.
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.
Fixed in 9cf6ede.
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.
Good, thanks for the updates.
A coin toss as to whether it needs a CSR as there isn't anything new or changed.
Thanks for the review. Are we not concerned about the other FAEEs mentioned above? |
Some of them are okay, e.g. copy has "if the target file exists but ...". If you have cycles, there are 7 cases that have "If a file of that name already exists and the CREATE_NEW ..." that could be improved if changed to "If the path locates an existing file and the CREATE_NEW ...". |
Yes, I will change them. |
Addressed in commit 3684b8c. |
|
Hello Brian, the changes look reasonable to me. Having said that, the JBS issue description states that the usage of the word "file" makes it sound like the exception is raised only if a regular file exists at the
and with the proposed change we now have:
So, I think, that wording will still leave readers wondering whether existing directory at that I am not proposing further changes though (I can't think of something that's more concise).
and it checks even for directories, so I think it's all consistent with the rest of the API docs. |
I think it's best to keep the API docs simple and consistent. I'm sure there are developers that don't think of a directory or sym files as "files" but once you attempt to clarify things then it gets complicated and it could potentially confusing a wider set of developers. |
Slightly changes the specification of
Files.createDirectoryto highlight that it fails if a filesystem entity already exists at the given location.Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/28378/head:pull/28378$ git checkout pull/28378Update a local copy of the PR:
$ git checkout pull/28378$ git pull https://git.openjdk.org/jdk.git pull/28378/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 28378View PR using the GUI difftool:
$ git pr show -t 28378Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/28378.diff
Using Webrev
Link to Webrev Comment