-
Notifications
You must be signed in to change notification settings - Fork 5.8k
8339850: Restore the interrupt status in FileSystemPreferences.lockFile() #20938
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 sbgoog! A progress list of the required criteria for merging this PR into |
@sbgoog 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 308 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. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@bplb, @djelinski, @vyommani) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
Webrevs
|
/reviewers 2 reviewer |
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.
Looks all right.
This PR needs another reviewer. Is there someone that can have a look at it? |
@djelinski ? @jaikiran ? |
@@ -958,6 +958,8 @@ private boolean lockFile(boolean shared) throws SecurityException{ | |||
Thread.sleep(sleepTime); | |||
} catch(InterruptedException e) { | |||
checkLockFile0ErrorCode(errorCode); | |||
// Don't lose the interrupt unless we throw. |
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.
Why should we lose the interrupted status if we throw a SecurityException? It doesn't look right.
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 thought that if an access error is found, then that would take precedence over the interrupt, especially since it occurs before the sleep. I was more concerned with just returning false and the caller not knowing if it's false due to interrupt, or false because the file could not be locked after all retries.
Certainly the interrupt status could move before the check which may through, but I think it's less likely that the status will be checked in a catch of SecurityException.
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 status might not be explicitly checked, but setting the interrupted status will make sure that subsequent calls to sleep/await/tryLock etc. will not block.
In general, we want to preserve the interrupted status until either the user decides that it's fine to clear, or until the thread dies.
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.
In which case the code might be simplified to just:
} catch (InterruptedException e) {
// Don't lose the interrupt
Thread.currentThread().interrupt();
break;
}
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've reworked the change to always set the interrupted status. I wouldn't remove the check of the error code here, as it'd be a behavior change. I can follow up with that, though it seems to me that it's good to still have the check for access error here.
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.
My suggestion was to break;
instead of return false;
which would fall through to line 967 where the check method would be called. But what you have is probably preferable as it preserves the original style and keep the changes minimal.
27cba44
to
0b03041
Compare
@sbgoog Please do not rebase or force-push to an active PR as it invalidates existing review comments. Note for future reference, the bots always squash all changes into a single commit automatically as part of the integration. See OpenJDK Developers’ Guide for more information. |
For future reference, as the bot says, don't force push. The bot will squash all commits before merging. The change looks good to me. Please update the copyright year. |
I didn't realize before pushing, but now I know. Thanks!
I've done that now. |
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.
Looks OK
/integrate |
/sponsor |
Going to push as commit 9fc1c68.
Your commit was automatically rebased without conflicts. |
FIleSystemPreferences.lockFile() catches an InterruptedException and just returns false, forgetting to re-interrupt the current thread. This leaves the caller with no way to observe that the thread was interrupted. This change restores the interrupted status on the current thread before returning.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/20938/head:pull/20938
$ git checkout pull/20938
Update a local copy of the PR:
$ git checkout pull/20938
$ git pull https://git.openjdk.org/jdk.git pull/20938/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 20938
View PR using the GUI difftool:
$ git pr show -t 20938
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/20938.diff
Webrev
Link to Webrev Comment