...
The JMM guarantees that the fully initialized values of fields that are declared final are safely published to every thread that reads those values at some point no later earlier than the end of the object's constructor.
...
Failure to synchronize access to shared mutable data can cause different threads to observe different states of the object or to observe a partially initialized object.
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
TSM03-J | Medium | Probable | Medium | P8 | L2 |
Automated Detection
Tool | Version | Checker | Description | ||||||
---|---|---|---|---|---|---|---|---|---|
CodeSonar |
| FB.MT_CORRECTNESS.DC_PARTIALLY_CONSTRUCTED | Possible exposure of partially initialized object |
Bibliography
[API 2006] |
Item 48, "Synchronize Access to Shared Mutable Data" | |
Section 3.5.3, "Safe Publication Idioms" | |
Pattern #2, "One-Time Safe Publication" | |
[JPL 2006] | Section 14.10.2, "Final Fields and Security" |
...
...