Skip to content

Commit

Permalink
8319925: CSS.BackgroundImage incorrectly uses double-checked locking
Browse files Browse the repository at this point in the history
Reviewed-by: aivanov
  • Loading branch information
prsadhuk committed Dec 7, 2023
1 parent 0048f1d commit 0b0fa47
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/java.desktop/share/classes/javax/swing/text/html/CSS.java
Original file line number Diff line number Diff line change
Expand Up @@ -2933,8 +2933,8 @@ public boolean equals(Object val) {
*/
@SuppressWarnings("serial") // Same-version serialization only
static class BackgroundImage extends CssValue {
private boolean loadedImage;
private ImageIcon image;
private volatile boolean loadedImage;
private ImageIcon image;

Object parseCssValue(String value) {
BackgroundImage retValue = new BackgroundImage();
Expand All @@ -2952,14 +2952,14 @@ ImageIcon getImage(URL base) {
synchronized(this) {
if (!loadedImage) {
URL url = CSS.getURL(base, svalue);
loadedImage = true;
if (url != null) {
image = new ImageIcon();
Image tmpImg = Toolkit.getDefaultToolkit().createImage(url);
if (tmpImg != null) {
image.setImage(tmpImg);
}
}
loadedImage = true;
}
}
}
Expand Down

1 comment on commit 0b0fa47

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.