[Fixes: #7462] Orchard.OutputCache - Possible NRE in DefaultTagCache ctor when accessing the WorkContext (#7463)

Fixes #7462
This commit is contained in:
Xceno Malloy
2016-12-08 21:20:54 +01:00
committed by Sébastien Ros
parent d0b65cb60b
commit 5c6dd3e34f

View File

@@ -17,13 +17,15 @@ namespace Orchard.OutputCache.Services {
var key = shellSettings.Name + ":TagCache";
var workContext = workContextAccessor.GetContext();
if ( workContext != null ) {
_dictionary = workContext.HttpContext.Cache.Get(key) as ConcurrentDictionary<string, HashSet<string>>;
if (_dictionary == null) {
if ( _dictionary == null ) {
_dictionary = new ConcurrentDictionary<string, HashSet<string>>(StringComparer.OrdinalIgnoreCase);
workContext.HttpContext.Cache.Add(key, _dictionary, null, Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration, CacheItemPriority.Normal, null);
}
}
}
public void Tag(string tag, params string[] keys) {
var set = _dictionary.GetOrAdd(tag, x => new HashSet<string>());