Synchronization on a non-final field
Reports synchronized
statement lock expressions that consist of a non-final
field reference. Such statements are unlikely to have useful semantics, as different threads may acquire different locks even when operating on the same object.
Locating this inspection
- By ID
Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.
SynchronizeOnNonFinalField- Via Settings dialog
Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.
Example:
private Object o;
public void foo() {
synchronized (o) // synchronization on a non-final field
{ }
}
Availability
- By default bundled with
- Can be installed with plugin
Java, 241.18072
Last modified: 18 June 2024