JCSWorker locks indefinitely - code fix provided.

Scott Archer <[email protected]> Fri, 4 Dec 2009 09:20:20 -0600
Newsgroups gmane.comp.jakarta.turbine.jcs.devel
Message-ID <[email protected]>
--000e0ce0425e5b7baf0479e8a5e0
Content-Type: text/plain; charset=ISO-8859-1

Is there any chance we could get this code into the trunk?
We're running off our own build now, and it would be nice to keep in sync
with any changes going forward.

We've implemented this code change and the fix is working great.

Thanks,

Scott


https://issues.apache.org/jira/browse/JCS-69

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();
 }

--000e0ce0425e5b7baf0479e8a5e0--