Uploaded image for project: 'Apache Cassandra'
  1. Apache Cassandra
  2. CASSANDRA-19763

Reentrant locks should always be locked outside of a try block

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Triage Needed
    • Low
    • Resolution: Unresolved
    • 5.x
    • 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

          Activity

            People

              maoling Ling Mao
              maoling Ling Mao
              Ling Mao
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 10m
                  10m