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 2010/07/10 01:26:24 UTC
svn commit: r962723 -
/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java
Author: lu4242
Date: Fri Jul 9 23:26:23 2010
New Revision: 962723
URL: http://svn.apache.org/viewvc?rev=962723&view=rev
Log:
MYFACES-2805 Use synchronized blocks for ApplicationImpl _defaultValidatorsIds
Modified:
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java?rev=962723&r1=962722&r2=962723&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java Fri Jul 9 23:26:23 2010
@@ -173,9 +173,9 @@ public class ApplicationImpl extends App
private final Map<Class<? extends SystemEvent>, SystemListenerEntry> _systemEventListenerClassMap = new ConcurrentHashMap<Class<? extends SystemEvent>, SystemListenerEntry>();
- private Map<String, String> _defaultValidatorsIds = new ConcurrentHashMap<String, String>();
+ private final Map<String, String> _defaultValidatorsIds = new HashMap<String, String>();
- private Map<String, String> _cachedDefaultValidatorsIds = null;
+ private volatile Map<String, String> _cachedDefaultValidatorsIds = null;
private final Map<String, Object> _behaviorClassMap = new ConcurrentHashMap<String, Object>();
@@ -287,9 +287,13 @@ public class ApplicationImpl extends App
//otherwise validatorClass is an object of type Class<?>
className = ((Class<?>)validatorClass).getName();
-
- _defaultValidatorsIds.put(validatorId, className);
- _cachedDefaultValidatorsIds = null;
+
+ // Ensure atomicity between _defaultValidatorsIds and _cachedDefaultValidatorsIds
+ synchronized(_defaultValidatorsIds)
+ {
+ _defaultValidatorsIds.put(validatorId, className);
+ _cachedDefaultValidatorsIds = null;
+ }
}
}
@@ -298,7 +302,13 @@ public class ApplicationImpl extends App
{
if (_cachedDefaultValidatorsIds == null)
{
- _cachedDefaultValidatorsIds = Collections.unmodifiableMap(_defaultValidatorsIds);
+ synchronized(_defaultValidatorsIds)
+ {
+ if (_cachedDefaultValidatorsIds == null)
+ {
+ _cachedDefaultValidatorsIds = Collections.unmodifiableMap(_defaultValidatorsIds);
+ }
+ }
}
return _cachedDefaultValidatorsIds;
}