Use ConcurrentDictionary in CachingScriptMetadataResolver#1627
Use ConcurrentDictionary in CachingScriptMetadataResolver#1627filipw merged 5 commits intoOmniSharp:masterfrom
Conversation
|
this type is duplicated for Cake too, could you fix it there too? https://github.com/OmniSharp/omnisharp-roslyn/blob/master/src/OmniSharp.Cake/CachingScriptMetadataResolver.cs |
| } | ||
|
|
||
| return result; | ||
| return MissingReferenceCache.GetOrAdd(referenceIdentity.Name, _ => _defaultReferenceResolver.ResolveMissingAssembly(definition, referenceIdentity)); |
There was a problem hiding this comment.
I don't think it's the same thing as before. the old code would only cache non-nulls, whereas the new code would cache them.
In the second case it wouldn't cache empty collections too
There was a problem hiding this comment.
Yeah, that is true, But does it matter? If the _defaultReferenceResolver returns null, it would be null for any subsequent requests too? So we save a call into the _defaultReferenceResolver. Unless that could change between request. If it actually is important we can replace this with TryAdd instead
There was a problem hiding this comment.
Or is it any other reason for this conditional caching? 😀
This PR fixes a bug that was caused by multiple threads accessing the
DirectReferenceCacheand theMissingReferenceCacheinside theCachingScriptMetadataResolverOccasionally, OmniSharp would fail to initialize for
csxfiles with the following output from theOmniSharplogThe fix is implemented by replacing the underlying
Dictionarywith aConcurrentDictionary