1

Closed

CanRead/WriteProperty methods not thread-safe

description

Following code is not thread-safe. Adding to _readResultsCache must be synchronized. This is true for CanReadProperty, CanWriteProperty and CanExecuteMethod methods.  [EditorBrowsable(EditorBrowsableState.Advanced)] public virtual bool CanReadProperty(string propertyName) { bool result = true;  VerifyAuthorizationCache();  if (!_readResultCache.TryGetValue(propertyName, out result)) { result = true; if (AuthorizationRules.HasReadAllowedRoles(propertyName)) { // some users are explicitly granted read access // in which case all other users are denied if (!AuthorizationRules.IsReadAllowed(propertyName)) result = false; } else if (AuthorizationRules.HasReadDeniedRoles(propertyName)) { // some users are explicitly denied read access if (AuthorizationRules.IsReadDenied(propertyName)) result = false; } // store value in cache _readResultCache.Add(propertyName, result); } return result; } Below is a partial stack-trace.  An item with the same key has already been added.at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) at System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add) at Csla.Core.BusinessBase.CanReadProperty(String propertyName) at Csla.Core.BusinessBase.CanReadProperty(String propertyName, Boolean throwOnFalse) at Csla.Core.BusinessBase.GetProperty[P](PropertyInfo1 propertyInfo, NoAccessBehavior noAccess) at Csla.Core.BusinessBase.GetProperty[P](PropertyInfo`1 propertyInfo) .......
Closed Nov 18, 2012 at 9:51 PM by tiago
Code generation support was discontinued as of Nov. 2010

comments

rasitha1 wrote Oct 21, 2009 at 3:28 PM

Ignore. I have added this to the wrong issue tracker.