Commons JCS
  1. Commons JCS
  2. JCS-21

JCS has inconsistent locking of shared data

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: jcs-1.2.7.9.2
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      I've been looking at the trunk JCS code with findbugs (http://findbugs.sf.net/).

      One of the things it does is warn when data is inconsistently synchronized - ie when it is sometimes referenced inside a synchronized block and sometimes not. This is not threadsafe - one thread may read old or inconsistent data.

      I've patched all the places findbugs complains about by adding appropriate synchronized() blocks.

      I suspect this change may require some discussion

      1. locking.diff
        8 kB
        Michael Stevens

        Activity

        Hide
        Michael Stevens added a comment -

        patch to jcs locking code

        Show
        Michael Stevens added a comment - patch to jcs locking code
        Hide
        Aaron Smuts added a comment -

        Find bugs is not perfect at locating sync problems. Far from it. I'll have to look at the changes. I've never seen it acurately loate a synchronization problem.

        Show
        Aaron Smuts added a comment - Find bugs is not perfect at locating sync problems. Far from it. I'll have to look at the changes. I've never seen it acurately loate a synchronization problem.
        Hide
        Michael Stevens added a comment -

        The principle I followed in the changes, which I suspect from the code you may disagree with, is that if you're sometimes locking access to a field, you always need to.

        Show
        Michael Stevens added a comment - The principle I followed in the changes, which I suspect from the code you may disagree with, is that if you're sometimes locking access to a field, you always need to.
        Hide
        Aaron Smuts added a comment -

        I think some of these are legitimate, but not practical problems since they are on non used methods, etc. I'll update with more details as I go over the list.

        Show
        Aaron Smuts added a comment - I think some of these are legitimate, but not practical problems since they are on non used methods, etc. I'll update with more details as I go over the list.
        Hide
        Aaron Smuts added a comment -

        I applied all the changes except for some private method changes and the optimization method on the indexed disk cache.

        Show
        Aaron Smuts added a comment - I applied all the changes except for some private method changes and the optimization method on the indexed disk cache.

          People

          • Assignee:
            Aaron Smuts
            Reporter:
            Michael Stevens
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development