-
Notifications
You must be signed in to change notification settings - Fork 492
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
8347392: Thread-unsafe implementation of c.s.j.scene.control.skin.Utils #1691
8347392: Thread-unsafe implementation of c.s.j.scene.control.skin.Utils #1691
Conversation
👋 Welcome back angorya! A progress list of the required criteria for merging this PR into |
@andy-goryachev-oracle 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 no new commits pushed to the ➡️ To integrate this PR with the above commit message to the |
|
@andy-goryachev-oracle |
Webrevs
|
@kevinrushforth I'd suggest to take a look at this first, as it blocks some other fixes. 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.
The fix looks good. My testing is good as well. The now-enabled tests fail pretty reliably for me on Windows without your fix and all pass with your fix.
I left a few minor questions / comments, but will approve as is.
@Disabled("JDK-8347392") // FIX | ||
@Test | ||
public void hyperlink() { |
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: setVisited(nextBoolean())
?
@Disabled("JDK-8347392") // FIX | ||
@Test | ||
public void checkBox() { |
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: this test calls setSelected(true)
. Would introducing randomness via setSelected(nextBoolean())
be useful 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.
here and elsewhere, you are right
@Disabled("JDK-8347392") // FIX | ||
@Test | ||
public void choiceBox() { |
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: select random item?
What's the rationale for using a borrow pattern here, instead of simply synchronizing access to the object in question? I don't think we use such a pattern anywhere else. Do you expect heavy contention? |
A very good question! This pattern seemed to be the most applicable here: the solution needs to be both thread-safe and reentrant, with the expectation that in most cases the simple scenario happens where the static instance is used. We actually use that pattern using synchronization, see Is there a specific scenario that would not work or cause issues? |
To add a little more to what Andy said, I think there are three main approaches that could have been used here:
There might be other solutions, but we don't want anything too complicated. Andy decided to go with 2. |
Hmmm, to further make a point: options 2 and 3 may not be re-entrant, so they probably won't work. We haven't encounter this re-entrancy issue, but I suppose it might be possible to have a text component embedded in another text component (e.g. a TextArea embedded inside a RichTextArea for some reason). Even if the access happens within the FX application thread, the inner layout might clobber the outer one. Thank you for a good discussion though! |
Your solution is basically what I meant by option 2. The way you did it, always using the return value of a method that will return a "safe" instance to use, is reentrant. You are right that a simple approach to option 3 would not be reentrant. I like the solution you chose. |
right. "only one thread" threw me off, sorry. |
/integrate |
@andy-goryachev-oracle Pushed as commit 2cf9779. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Thread-safe and re-entrant implementation of Utils.
The new code still uses the static instances of Text and TextLayout for performance reasons, but adds a thread-safe mechanism to keep track of whether any of the instances is in use and when that happens, supplies a new instance instead. This solves both thread safety and re-entrancy.
/reviewers 2
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/1691/head:pull/1691
$ git checkout pull/1691
Update a local copy of the PR:
$ git checkout pull/1691
$ git pull https://git.openjdk.org/jfx.git pull/1691/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 1691
View PR using the GUI difftool:
$ git pr show -t 1691
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/1691.diff
Using Webrev
Link to Webrev Comment