Inconsistent synchronization of getter and setter¶
ID: java/unsynchronized-getterKind: problemSecurity severity: Severity: errorPrecision: very-highTags: - quality - reliability - concurrency - language-features - external/cwe/cwe-413 - external/cwe/cwe-662Query suites: - java-security-and-quality.qls
Click to see the query in the CodeQL repository
If a class has a synchronizedset method and a similarly-namedget method is not also synchronized, calls to theget method may not return a consistent state for the object.
Recommendation¶
Synchronize read operations as well as write operations. You should usually synchronize theget method.
References¶
Java Language Specification:Synchronization.
Common Weakness Enumeration:CWE-413.
Common Weakness Enumeration:CWE-662.