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 are creating new EnumValue instances on multiple threads there is a possibility of collisions causing run-time failures.
This was observed when creating Energistics.DataAccess.WITSML141.QualifierType instances on multiple threads threw an InvalidOperationException as you cannot modify a collection when iterating over it.
Technical details
The issue is in the Register() method in Energistics.DataAccess.EnumValue. This accesses a static ConcurrentDictionary<Type, List<EnumValue>> instance.
The issue is that although the ConcurrentDictionary is thread-safe the List it returns is not.
The Register() method both iterates over this List and can add new elements to it.
Therefore you can have Thread A iterating over the list while Thread B simultaneously modifies it causing Thread A to throw an exception.
The text was updated successfully, but these errors were encountered:
Summary
If you are creating new
EnumValue
instances on multiple threads there is a possibility of collisions causing run-time failures.This was observed when creating
Energistics.DataAccess.WITSML141.QualifierType
instances on multiple threads threw anInvalidOperationException
as you cannot modify a collection when iterating over it.Technical details
The issue is in the
Register()
method inEnergistics.DataAccess.EnumValue
. This accesses a staticConcurrentDictionary<Type, List<EnumValue>>
instance.The issue is that although the
ConcurrentDictionary
is thread-safe theList
it returns is not.The
Register()
method both iterates over thisList
and can add new elements to it.Therefore you can have Thread A iterating over the list while Thread B simultaneously modifies it causing Thread A to throw an exception.
The text was updated successfully, but these errors were encountered: