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/07/11 22:06:13 UTC
svn commit: r1145322 -
/myfaces/core/branches/1.2.x/api/src/main/java/javax/faces/component/_ComponentAttributesMap.java
Author: lu4242
Date: Mon Jul 11 20:06:13 2011
New Revision: 1145322
URL: http://svn.apache.org/viewvc?rev=1145322&view=rev
Log:
MYFACES-3216 check concurrency problems over static maps holding class metadata information (_ComponentAttributesMap and MetaRulesetImpl)
Modified:
myfaces/core/branches/1.2.x/api/src/main/java/javax/faces/component/_ComponentAttributesMap.java
Modified: myfaces/core/branches/1.2.x/api/src/main/java/javax/faces/component/_ComponentAttributesMap.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/1.2.x/api/src/main/java/javax/faces/component/_ComponentAttributesMap.java?rev=1145322&r1=1145321&r2=1145322&view=diff
==============================================================================
--- myfaces/core/branches/1.2.x/api/src/main/java/javax/faces/component/_ComponentAttributesMap.java (original)
+++ myfaces/core/branches/1.2.x/api/src/main/java/javax/faces/component/_ComponentAttributesMap.java Mon Jul 11 20:06:13 2011
@@ -360,7 +360,15 @@ class _ComponentAttributesMap
}
}
// ... and put it in cache
- _propertyDescriptorCache.put(_component.getClass(), _propertyDescriptorMap);
+ synchronized(_propertyDescriptorCache)
+ {
+ // Use a synchronized block to ensure proper operation on concurrent use cases.
+ // This is a racy single check, because initialization over the same class could happen
+ // multiple times, but the same result is always calculated. The synchronized block
+ // just ensure thread-safety, because only one thread will modify the cache map
+ // at the same time.
+ _propertyDescriptorCache.put(_component.getClass(), _propertyDescriptorMap);
+ }
}
}
return _propertyDescriptorMap.get(key);
@@ -460,4 +468,4 @@ class _ComponentAttributesMap
{
return _attributes.hashCode();
}
-}
\ No newline at end of file
+}