Uploaded image for project: 'Commons JCS'
  1. Commons JCS
  2. JCS-69

Synchronization Problem in JCSWorker

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • jcs-1.3, jcs-2.0-beta-1
    • jcs-2.0-beta-1
    • None
    • None
    • Linux 2.6.28-15-generic #52-Ubuntu SMP Wed Sep 9 10:48:52 UTC 2009 x86_64 GNU/Linux
      java version "1.6.0_16"
      Java(TM) SE Runtime Environment (build 1.6.0_16-b01)
      Java HotSpot(TM) 64-Bit Server VM (build 14.2-b01, mixed mode)

    Description

      When using the JCSWorker threads lock indefinitely.
      I believe the synchronized block in the finally block is synchronizing on and notifying the wrong object.

      Once a thread locks it never unlocks.

      Class: org.apache.jcs.utils.access.JCSWorker
      Method: private Object run( Serializable aKey, String aGroup, JCSWorkerHelper aHelper ) throws Exception

      Bad Code (in finally block):
      synchronized ( this )

      { aHelper.setFinished( true ); // Wake everyone waiting on us notifyAll(); }

      Suggested Fix:
      synchronized ( aHelper )

      { aHelper.setFinished( true ); // Wake everyone waiting on aHelper aHelper.notifyAll(); }

      Attachments

        1. cache.ccf
          0.4 kB
          Scott Archer
        2. JCSTest.java
          2 kB
          Scott Archer

        Activity

          People

            asmuts Aaron Smuts
            scarcher2 Scott Archer
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: