Empty 'synchronized' statement
Reports synchronized
statements with empty bodies.
Empty synchronized
statements are sometimes used to wait for other threads to release a particular resource. However, there is no guarantee that the same resource won't be acquired again right after the empty synchronized
statement finishes. For proper synchronization, the resource should be utilized inside the synchronized
block.
Also, an empty synchronized
block may appear after a refactoring when redundant code was removed. In this case, the synchronized
block itself will be redundant and should be removed as well.
Example:
A quick-fix is suggested to remove the empty synchronized statement.
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.
EmptySynchronizedStatement- 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.
This inspection is disabled in JSP files.
Inspection Details | |
---|---|
By default bundled with: | |
Can be installed with plugin: | Java, 243.23126 |