[jboss-jira] [JBoss JIRA] Updated: (JGRP-1278) LockService lock, tryLock methods don't work well with interrupt

William Burns (JIRA) jira-events at lists.jboss.org
Fri Jan 21 19:26:49 EST 2011


     [ https://issues.jboss.org/browse/JGRP-1278?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

William Burns updated JGRP-1278:
--------------------------------

    Attachment: Locking.java.patch


Patch file that contains 2 different types of fixes

1. Fix for lock() and tryLock() methods to not return upon interrupt and instead to try to acquire the lock and then set the interrupt status upon return if was interrupted
2. Fix for lockInterruptibly and tryLock(long, TimeUnit) so that when they throw an InterruptedException they will properly clean up their lock requests.

> LockService lock, tryLock methods don't work well with interrupt
> ----------------------------------------------------------------
>
>                 Key: JGRP-1278
>                 URL: https://issues.jboss.org/browse/JGRP-1278
>             Project: JGroups
>          Issue Type: Bug
>    Affects Versions: 2.12
>            Reporter: William Burns
>            Assignee: Bela Ban
>         Attachments: Locking.java.patch
>
>
> I have been trying out the new LockService class, which has been great to use.
> However I began looking into stuff around interrupts, and while glancing at the actual protocol code I became a little confused as to how the lock method would ignore an interrupt and still acquire the lock.  So I wrote up a simple test case, which can be found in the Reproduce section.
> Needless to say the lock method behaves completely differently than how I would have expected if an interrupt was encountered.  If the interrupt flag is set the lock method would return immediately, making the caller think the lock was retrieved.  However the lock was not retrieved!  Also not to mention the interrupt status was lost completely, further preventing the interrupt from being checked in a later part of code.
> Also the tryLock() method behaves somewhat in a similar fashion as lock.  If the interrupt status is set it will return false immediately and clear the interrupt status.  I would expect the code to still retrieve the lock if possible and leave the interrupt flag set afterwards just like I would in the case of lock.
> I did also test the lockInterruptibly, tryLock(long, TimeUnit) and those worked if the interrupt flag was set before invoking it, by throwing an InterruptedException as expected.
> I didn't test any of the methods in regards to an interrupt being done in the middle of waiting to acquire a lock.

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the jboss-jira mailing list