You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2011/10/27 19:38:07 UTC

svn commit: r1189886 - /myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/util/AbstractThreadSafeAttributeMap.java

Author: lu4242
Date: Thu Oct 27 17:38:06 2011
New Revision: 1189886

URL: http://svn.apache.org/viewvc?rev=1189886&view=rev
Log:
MYFACES-3377 unsynchronized lazy initialization could create concurrency errors

Modified:
    myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/util/AbstractThreadSafeAttributeMap.java

Modified: myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/util/AbstractThreadSafeAttributeMap.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/util/AbstractThreadSafeAttributeMap.java?rev=1189886&r1=1189885&r2=1189886&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/util/AbstractThreadSafeAttributeMap.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/util/AbstractThreadSafeAttributeMap.java Thu Oct 27 17:38:06 2011
@@ -37,9 +37,9 @@ import java.util.Set;
  */
 public abstract class AbstractThreadSafeAttributeMap<V> extends AbstractMap<String, V>
 {
-    private Set<String> _keySet;
-    private Collection<V> _values;
-    private Set<Entry<String, V>> _entrySet;
+    private Set<String> _keySet = new KeySet();
+    private Collection<V> _values =  new Values();
+    private Set<Entry<String, V>> _entrySet = new EntrySet();
 
     @Override
     public void clear()
@@ -81,7 +81,7 @@ public abstract class AbstractThreadSafe
     @Override
     public Set<Entry<String, V>> entrySet()
     {
-        return (_entrySet != null) ? _entrySet : (_entrySet = new EntrySet());
+        return _entrySet;
     }
 
     @Override
@@ -99,7 +99,7 @@ public abstract class AbstractThreadSafe
     @Override
     public Set<String> keySet()
     {
-        return (_keySet != null) ? _keySet : (_keySet = new KeySet());
+        return _keySet;
     }
 
     @Override
@@ -143,7 +143,7 @@ public abstract class AbstractThreadSafe
     @Override
     public Collection<V> values()
     {
-        return (_values != null) ? _values : (_values = new Values());
+        return _values;
     }
 
     abstract protected V getAttribute(String key);
@@ -396,19 +396,29 @@ public abstract class AbstractThreadSafe
         public boolean equals(final Object obj)
         {
             if (this == obj)
+            {
                 return true;
+            }
             if (obj == null)
+            {
                 return false;
+            }
             if (getClass() != obj.getClass())
+            {
                 return false;
+            }
             final EntrySetEntry other = (EntrySetEntry)obj;
             if (_currentKey == null)
             {
                 if (other._currentKey != null)
+                {
                     return false;
+                }
             }
             else if (!_currentKey.equals(other._currentKey))
+            {
                 return false;
+            }
             return true;
         }