StorageCache is not thread safe


My web application is having some race conditions. I dived deep into StorageCache class. I believe I have found the cause:
itemResultCache, attributesResultCache and ldapQueryResults are shared across all threads.
In a web application, StorageCache object is a singleton and shared across all threads. But itemResultCache, attributesResultCache and ldapQueryResults are really meant to be used only by one thread (single call).
In my case, when CheckAccess->storeApplicationItemValidation is called, the following two lines are executed:
        this.itemResultCache = Hashtable.Synchronized(new Hashtable());
        this.attributesResultCache = Hashtable.Synchronized(new Hashtable());
After that, all the threads are looking at two empty caches. All the data is lost.
Suggestion: Make these cache objects to be thread data or CallContext data.
It's an urgent issue on our side, please let me know your time line ASAP. I may need do some custom coding.
Closed Feb 2, 2012 at 4:24 AM by tangrl


aferende wrote Jan 29, 2012 at 9:46 AM

Hi Richard,
could you make the suggested code changes ?
If you want, I can add you as developer.

Let me know.

tangrl wrote Jan 30, 2012 at 3:43 PM

Sure, I can make the changes and test it here first. Please add me as a developer and let me know the best way to send you the code changes.



aferende wrote Jan 30, 2012 at 10:18 PM

I added you as a Team Developer.
To make changes please use Visual Studio 2010 connected with Team Explorer.
See here: http://codeplex.codeplex.com/wikipage?title=Using%20TFS%20and%20Team%20Explorer%20with%20CodePlex


wrote Jan 31, 2012 at 4:45 AM

wrote Feb 2, 2012 at 4:24 AM

Resolved with changeset 73899.

wrote Feb 22, 2013 at 12:33 AM

wrote May 16, 2013 at 12:00 PM