Details
-
Improvement
-
Status: Triage Needed
-
Low
-
Resolution: Unresolved
-
None
-
None
-
All
-
None
Description
Acquiring the lock should always be done before the try block so that the finally clause to unlock will never execute unless the lock is acquired. More info:
https://stackoverflow.com/questions/31058681/java-locking-structure-best-pattern https://issues.apache.org/jira/browse/AMQ-9202
Unfortunately, there are no ready-made rules in Checkstyle, FindBugs, or SpotBugs for this type of violation checking. I use "IDEA inspection" to identify all such violations.
IDEA Code -> Analyze Code -> Run Inspection by Name(Lock acquired but not safely unlocked) ---> Whole project
Attachments
Issue Links
- links to