summaryrefslogtreecommitdiff
path: root/javax/swing/text
diff options
context:
space:
mode:
authorRoman Kennke <roman@kennke.org>2006-11-20 10:33:41 +0000
committerRoman Kennke <roman@kennke.org>2006-11-20 10:33:41 +0000
commitec3880456fce8eee43bbb10fdc073326aae69f48 (patch)
tree0f23b43b67b0d9f54de4df58c2fc336a1266561e /javax/swing/text
parentb237d32d46a79e0c12adf98141bbe24ecb53ecdb (diff)
downloadclasspath-ec3880456fce8eee43bbb10fdc073326aae69f48.tar.gz
2006-11-20 Roman Kennke <kennke@aicas.com>
* javax/swing/text/StyleContext.java (attributeSetPool): Synchronize this map. (addAttribute): Synchronize this method. (addAttributes: Synchronize this method. (readObject): Install synchronized map on target object. (removeAttribute): Synchronize this method. (removeAttributes): Synchronize this method. (removeAttributes): Synchronize this method.
Diffstat (limited to 'javax/swing/text')
-rw-r--r--javax/swing/text/StyleContext.java22
1 files changed, 15 insertions, 7 deletions
diff --git a/javax/swing/text/StyleContext.java b/javax/swing/text/StyleContext.java
index 69df573c2..238fabb9d 100644
--- a/javax/swing/text/StyleContext.java
+++ b/javax/swing/text/StyleContext.java
@@ -48,10 +48,12 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.lang.ref.WeakReference;
+import java.util.Collections;
import java.util.Enumeration;
import java.util.EventListener;
import java.util.Hashtable;
import java.util.Iterator;
+import java.util.Map;
import java.util.WeakHashMap;
import javax.swing.event.ChangeEvent;
@@ -467,7 +469,8 @@ public class StyleContext
/**
* A pool of immutable AttributeSets.
*/
- private transient WeakHashMap attributeSetPool = new WeakHashMap();
+ private transient Map attributeSetPool =
+ Collections.synchronizedMap(new WeakHashMap());
/**
* Creates a new instance of the style context. Add the default style
@@ -545,7 +548,7 @@ public class StyleContext
throws ClassNotFoundException, IOException
{
search = new SimpleAttributeSet();
- attributeSetPool = new WeakHashMap();
+ attributeSetPool = Collections.synchronizedMap(new WeakHashMap());
in.defaultReadObject();
}
@@ -650,7 +653,8 @@ public class StyleContext
return defaultStyleContext;
}
- public AttributeSet addAttribute(AttributeSet old, Object name, Object value)
+ public synchronized AttributeSet addAttribute(AttributeSet old, Object name,
+ Object value)
{
AttributeSet ret;
if (old.getAttributeCount() + 1 < getCompressionThreshold())
@@ -670,7 +674,8 @@ public class StyleContext
return ret;
}
- public AttributeSet addAttributes(AttributeSet old, AttributeSet attributes)
+ public synchronized AttributeSet addAttributes(AttributeSet old,
+ AttributeSet attributes)
{
AttributeSet ret;
if (old.getAttributeCount() + attributes.getAttributeCount()
@@ -701,7 +706,8 @@ public class StyleContext
cleanupPool();
}
- public AttributeSet removeAttribute(AttributeSet old, Object name)
+ public synchronized AttributeSet removeAttribute(AttributeSet old,
+ Object name)
{
AttributeSet ret;
if (old.getAttributeCount() - 1 <= getCompressionThreshold())
@@ -721,7 +727,8 @@ public class StyleContext
return ret;
}
- public AttributeSet removeAttributes(AttributeSet old, AttributeSet attributes)
+ public synchronized AttributeSet removeAttributes(AttributeSet old,
+ AttributeSet attributes)
{
AttributeSet ret;
if (old.getAttributeCount() <= getCompressionThreshold())
@@ -741,7 +748,8 @@ public class StyleContext
return ret;
}
- public AttributeSet removeAttributes(AttributeSet old, Enumeration names)
+ public synchronized AttributeSet removeAttributes(AttributeSet old,
+ Enumeration names)
{
AttributeSet ret;
if (old.getAttributeCount() <= getCompressionThreshold())