6853617: race condition in java.awt.Font.getAttributes() (private method)
authorprr
Mon, 22 Jun 2009 14:10:09 -0700
changeset 3017 217bf37bb0ea
parent 3016 2b51287517f1
child 3018 db307834eb9b
6853617: race condition in java.awt.Font.getAttributes() (private method) Reviewed-by: igor, jgodinez
jdk/src/share/classes/java/awt/Font.java
--- a/jdk/src/share/classes/java/awt/Font.java	Mon Jun 22 09:47:50 2009 -0700
+++ b/jdk/src/share/classes/java/awt/Font.java	Mon Jun 22 14:10:09 2009 -0700
@@ -445,18 +445,19 @@
      */
     private AttributeValues getAttributeValues() {
         if (values == null) {
-            values = new AttributeValues();
-            values.setFamily(name);
-            values.setSize(pointSize); // expects the float value.
+            AttributeValues valuesTmp = new AttributeValues();
+            valuesTmp.setFamily(name);
+            valuesTmp.setSize(pointSize); // expects the float value.
 
             if ((style & BOLD) != 0) {
-                values.setWeight(2); // WEIGHT_BOLD
+                valuesTmp.setWeight(2); // WEIGHT_BOLD
             }
 
             if ((style & ITALIC) != 0) {
-                values.setPosture(.2f); // POSTURE_OBLIQUE
+                valuesTmp.setPosture(.2f); // POSTURE_OBLIQUE
             }
-            values.defineAll(PRIMARY_MASK); // for streaming compatibility
+            valuesTmp.defineAll(PRIMARY_MASK); // for streaming compatibility
+            values = valuesTmp;
         }
 
         return values;