Discussions on double-checked lock on the internet illustrate without a shadow of doubt that volatile modifier is not required for 32 bit integers.
Commit c5ae991 guarantees INITIALIZATION_STATE variable in {{LoggerFactory is consistent even for multi-thread initializations. More specifically, only one thread will observe INITIALIZATION_STATE as UNINITIALIZED with all other threads observing either ONGOING_INITIALIZATION or the final result of the initialization. However, SLF4J initialization is still non-blocking and re-entrant, in the sense that if some thread tries to obtain loggers during ongoing initialization by another (or same) thread, instances of SubstituteLogger are returned.
The downside of the fix is that log calls during initialization will be dropped. In future versions of SLF4J we will be able to retain the data of the log calls and replay them post-initialization.
|