Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8319925

CSS.BackgroundImage incorrectly uses double-checked locking

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 22
    • 7, 8, 11, 17, 21
    • client-libs

      CSS.BackgroundImage.getImage uses double-checked locking but the loadedImage field isn't declared as volatile. Without the volatile modifier, double-checked locking implementation is broken.

      https://github.com/openjdk/jdk/blob/c9657cad124d2be10b8d6006d0ca9a038b1c5945/src/java.desktop/share/classes/javax/swing/text/html/CSS.java#L2950-L2955

      https://shipilev.net/blog/2014/safe-public-construction/#_safe_publication
      https://en.wikipedia.org/wiki/Double-checked_locking#Usage_in_Java
      https://www.oracle.com/technical-resources/articles/javase/bloch-effective-08-qa.html // Search for "double-check idiom", the article has no anchors.

            psadhukhan Prasanta Sadhukhan
            aivanov Alexey Ivanov
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: