Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed concurrency issues in the TypeCache class. #758

Merged

Conversation

VladimirKhvostov
Copy link
Contributor

TypeCache class has testAssemblyInfoCache and classInfoCache data members of type Dictionary<>.

Updates where under the lock, but reads were not, which sometimes causes the following error:

An exception occurred while invoking executor 'executor://mstestadapter/v2': One or more errors occurred. (Object reference not set to an instance of an object.) while running test
Stack:

---> System.NullReferenceException: Object reference not set to an instance of an object.
   at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
   at System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value)
   at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.TypeCache.GetClassInfo(TestMethod testMethod)
   at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.TypeCache.GetTestMethodInfo(TestMethod testMethod, ITestContext testContext, Boolean captureDebugTraces)
   at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.UnitTestRunner.RunSingleTest(TestMethod testMethod, IDictionary`2 testContextProperties)

This PR fixes this issue by switching to ConcurrentDictionary.

@Sanan07
Copy link
Contributor

Sanan07 commented Jan 15, 2021

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

@Haplois Haplois left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Haplois Haplois merged commit 126ea1f into microsoft:master Jan 21, 2021
@Haplois
Copy link
Contributor

Haplois commented Jan 21, 2021

Merged. Thank you, @VladimirKhvostov, for your contribution!

@VladimirKhvostov VladimirKhvostov deleted the users/vladimir/TypeCacheFix branch January 25, 2021 21:26
@AbhitejJohn
Copy link
Contributor

Thanks for fixing this all up @VladimirKhvostov.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants