-
Notifications
You must be signed in to change notification settings - Fork 8
Description
Since converters are stored in a Dictionary and there is no access synchronization, the method MsgPackContext.GetConverter<T> is not thread-safe. This becomes a problem when a converter is registered with RegisterGenericConverter like it is done here. The concrete generic types are becoming known to the serializer, who creates the converters with the non-thread-safe method, at the moment of serialization, and this may cause concurrent mutating GetConverter<T> calls.
So, as far as I understand, we must explicitly create the converters for all the concrete generic types and all the enums that may be serialized when creating MsgPackContext. This forces anyone who creates an MsgPackContext instance, for example the creator of ProGaudi.Tarantool.Client.Box in places like this, to be aware of every possible type that may be thrown at the serializer. This is quite inconvenient.
Why not switch to ConcurrentDictionary or synchronize access to Dictionary in MsgPackContext and get rid of this problem?