Query module SynchSetUnsynchGet

name
Inconsistent synchronization of getter and setter
description
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.
kind
problem
problem.severity
error
precision
very-high
id
java/unsynchronized-getter
tags
reliability correctness concurrency language-features external/cwe/cwe-413 external/cwe/cwe-662

Imports

java

Provides all default Java QL imports.

Predicates

bothAccessVolatileField

Holds if get is a getter method for a volatile field that set writes to.

isSynchronizedByBlock

Holds if this method is synchronized by a synchronized(Foo.class){...} block (for static methods) or a synchronized(this){...} block (for instance methods).