The language registry kept a dictionary of codes to indices beside a list of
translations, and mutated both without synchronisation while every localized
string in the product read them. Removing a language renumbered the rest, so a
reader could take an index under one numbering and read the list under another -
not a torn read but a wrong answer, one language's text returned under another's
code, and an index out of range when the list had shrunk.
A language is now addressed by its code rather than by a position, so there is
nothing left to renumber. Writers build the next map and publish it with a
single assignment under a lock, never touching a map that has been published;
a reader takes one snapshot and reads it to the end, so resolving the active
language and translating against it can no longer disagree. Lookups stay free of
locks and of interlocked operations, which matters on a path every string takes.
The generated properties had the same defect one floor up: each cached its text
in a field that ResetCache set back to null, so a reader that began before a
language changed could write its stale word into the cache afterwards and leave
it there for good. The cache is now an object that is replaced whole, published
after the registry, so a reader that sees the new cache sees the new registry
too.
Four tests were leaving process-wide registrations behind them for whatever ran
next, and two of those ran in the parallel phase.
Source codes for Messages, BE, Algo, Xaml, Localization, Logging, Community and few connectors (SmartCOM, AlfaDirect, Transaq, BTCE, OpenECry, LMAX, MatLab, CQG, Sterling, RSS, Alor)