← 返回首页
Inconsistent synchronization of getter and setter — CodeQL query help documentation CodeQL docs
CodeQL documentation
CodeQL resources

Inconsistent synchronization of getter and setter

ID: java/unsynchronized-getter Kind: problem Security severity: Severity: error Precision: very-high Tags: - quality - reliability - concurrency - language-features - external/cwe/cwe-413 - external/cwe/cwe-662 Query suites: - java-code-quality.qls - java-security-and-quality.qls

Click to see the query in the CodeQL repository

If a class has a synchronized set method and a similarly-named get method is not also synchronized, calls to the get method may not return a consistent state for the object.

Recommendation

Synchronize read operations as well as write operations. You should usually synchronize the get method.

References