You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you call GetOrAdd simultaneously on different threads, valueFactory may be called multiple times, but only one key/value pair will be added to the dictionary.
Although this remark is also present in versions of the documentation for frameworks for netcoreapp2.x and earlier, I was unable to reproduce the bug in those versions, suggesting that the chance of valueFactory being called multiple times increased significantly in netcoreapp3.0.
The text was updated successfully, but these errors were encountered:
Version(s)
From 2.0.0 to 3.7.1 inclusive.
To reproduce
Steps to reproduce the behaviour:
netcoreapp3.0
or later--parallel
option.Expected behaviour
Actual behaviour
Workarounds
Target
netcoreapp2.x
or earlier, or do not use the--parallel
option.Additional context
Thanks to @alibresco for raising #619 which led to discovery of the bug!
It is due to the behaviour of ConcurrentDictionary.GetOrAdd:
Although this remark is also present in versions of the documentation for frameworks for
netcoreapp2.x
and earlier, I was unable to reproduce the bug in those versions, suggesting that the chance ofvalueFactory
being called multiple times increased significantly innetcoreapp3.0
.The text was updated successfully, but these errors were encountered: