-
Notifications
You must be signed in to change notification settings - Fork 5.8k
8325179: Race in BasicDirectoryModel.validateFileCache #18111
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
8325179: Race in BasicDirectoryModel.validateFileCache #18111
Conversation
The method is not needed: fid != fetchID.get() cancels it
The method doesn't need to be synchronised as the object isn't accessed concurrently and all its fields are final.
The value is assigned to 'runnable' on this thread only; The value is read on this thread only (to pass to invokeLater)
👋 Welcome back aivanov! A progress list of the required criteria for merging this PR into |
@aivanov-jdk The following label will be automatically applied to this pull request:
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. |
/reviewers 2 |
Webrevs
|
@aivanov-jdk |
/issue add 8238169 |
@aivanov-jdk |
This fix also resolves JDK-8238169 because the |
@mrserb, could you take a look, please? |
src/java.desktop/share/classes/javax/swing/plaf/basic/BasicDirectoryModel.java
Outdated
Show resolved
Hide resolved
src/java.desktop/share/classes/javax/swing/plaf/basic/BasicDirectoryModel.java
Outdated
Show resolved
Hide resolved
src/java.desktop/share/classes/javax/swing/plaf/basic/BasicDirectoryModel.java
Outdated
Show resolved
Hide resolved
@@ -395,7 +394,7 @@ public DoChangeContents call() { | |||
} | |||
if (!fileCache.equals(newFileCache)) { | |||
if (loadThread.isInterrupted()) { | |||
cancelRunnables(); | |||
return null; |
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.
This should've been return null
all the way.
src/java.desktop/share/classes/javax/swing/plaf/basic/BasicDirectoryModel.java
Outdated
Show resolved
Hide resolved
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.
If this makes that CCME go away I'll be pleased.
I am assuming you've run the "full" battery of tests on this.
@aivanov-jdk 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 255 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 |
@prrace CCME is already gone, Tejesh and I resolved it under JDK-8323670 in #17462.
Yes, I did. No failures found. This is an isolated change, it prevents creating several background thread to load files. |
The With this fix, the test passes without OOME on Windows. At each given time, there's no more than one background thread loading the list of files. |
@mrserb Do you have any comments? |
src/java.desktop/share/classes/javax/swing/plaf/basic/BasicDirectoryModel.java
Show resolved
Hide resolved
/integrate |
Going to push as commit e66788c.
Your commit was automatically rebased without conflicts. |
@aivanov-jdk Pushed as commit e66788c. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Ensure access to the
filesLoader
field ofBasicDirectoryModel
is synchronized.Without synchronization, a thread checks if
filesLoader
is not null and creates a newFilesLoader
thread. If the thread is pre-empted between these two operations, another thread or even several threads can see thenull
value and create newFilesLoader
threads.The same way,
BasicDirectoryModel.invalidateFileCache
needs to be synchornized to interrupt the currentfilesLoader
and assignnull
.This bug allows reproducing
ConcurrentModificationException
seen in JDK-8323670 and JDK-8307091 using the test in PR #18109.Progress
Issues
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/18111/head:pull/18111
$ git checkout pull/18111
Update a local copy of the PR:
$ git checkout pull/18111
$ git pull https://git.openjdk.org/jdk.git pull/18111/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 18111
View PR using the GUI difftool:
$ git pr show -t 18111
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/18111.diff
Webrev
Link to Webrev Comment