locked section misfire
Greetingz,
take a look at the code at the bottom, which is being used by a multithreaded WebApplication.
Resharper says "Expression is always null", now consider 2 threads entering this code. 1st thread creates new container, while 2nd will only check if upon entering the locked section container is being created, so the /*XXX*/container= assignment will have another meaning.
ReSharperSetup.7.0.61.135
private static IDictionary<decimal, object> Container
{
get
{
var key = "123";
var container = HttpContext.Current.Application[key] as IDictionary<decimal, object>;
if (container == null)
{
lock (_syncContainer)
{
// Resharper: Destination has the same value before assignment
/*XXX*/ container = HttpContext.Current.Application[key] as IDictionary<decimal, object>; // Resharper: Expression is always null
if (container == null)
{
container = new ConcurrentDictionary<decimal, object>();
HttpContext.Current.Application[key] = container;
}
}
}
return container;
}
}
Please sign in to leave a comment.
Hello Max
Thank you for reporting this problem! I've logged it under http://youtrack.jetbrains.com/issue/RSRP-310008 and you're welcome to monitor its status.
Andrey Serebryansky
Senior Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"