changeset 1362:fafa991c27ac

6853617: race condition in java.awt.Font.getAttributes() (private method) Reviewed-by: igor, jgodinez
author prr
date Mon, 22 Jun 2009 14:10:09 -0700
parents 70903e2c39e3
children 2886eb650801
files src/share/classes/java/awt/Font.java
diffstat 1 files changed, 7 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/awt/Font.java	Mon Jun 22 09:47:50 2009 -0700
+++ b/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;