Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make
ConverterManager.getInstance()
init thread-safe.
We encountered a TSAN error because 2 threads were racing to call `ConverterManager.getInstance()`. My read is that the current code could actually be unsafe, since one thread might see `INSTANCE` as non-null before the other thread has initialized its fields. Fortunately, this looks like a good case for [the initialization-on-demand holder idiom](https://www.cs.umd.edu/~pugh/java/memoryModel/jsr-133-faq.html#:~:text=initialization%20on%20demand%20holder%20idiom). (There would be additional thread-safety concerns if anyone were to try to _mutate_ the `ConverterManager` instance concurrently with usage. But I'm not sure there's a solution to that short of spraying `synchronized` around. That seems like probably overkill, given the possible performance impact for what I'd hope is an uncommon use case.)
- Loading branch information