...
Failure to ensure the atomicity of two or more operations that must be performed as a single atomic operation can result in race conditions in multithreaded applications.
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
VNA03-J | Low | Probable | Medium | P4 | L3 |
Automated Detection
Some static analysis tools are capable of detecting violations of this rule.
Tool | Version | Checker | Description |
---|---|---|---|
CodeSonar | 4.2 | FB.MT_CORRECTNESS.IS2_INCONSISTENT_SYNC FB.MT_CORRECTNESS.IS_FIELD_NOT_GUARDED FB.MT_CORRECTNESS.STCAL_INVOKE_ON_STATIC_CALENDAR_INSTANCE FB.MT_CORRECTNESS.STCAL_INVOKE_ON_STATIC_DATE_FORMAT_INSTANCE FB.MT_CORRECTNESS.STCAL_STATIC_CALENDAR_INSTANCE FB.MT_CORRECTNESS.STCAL_STATIC_SIMPLE_DATE_FORMAT_INSTANCE | Inconsistent synchronization Field not guarded against concurrent access Call to static Calendar Call to static DateFormat Static Calendar field Static DateFormat |
Coverity | 7.5 | ATOMICITY | Implemented |
Parasoft Jtest |
|
|
| TRS.SSUG |
TRS.MRAV |
Make the get method for a field synchronized if the set method is synchronized Access related Atomic variables in a synchronized block | |||||||||
ThreadSafe |
| CCE_CC_NON_ATOMIC_GCP | Implemented |
Related Guidelines
CWE-362, Concurrent Execution Using Shared Resource with Improper Synchronization ("Race Condition") |
Bibliography
[API 2014] |
Section 4.4.1, "Client-side Locking" | |
Section 8.2, Synchronization and Collection Classes | |
[Lee 2009] | Map & Compound Operation |
...
...