ReentrantLock.isLocked() returns incorrect value
------------------------------------------------

                 Key: CDV-859
                 URL: https://jira.terracotta.org/jira//browse/CDV-859
             Project: Community Development
          Issue Type: Bug
    Affects Versions: 2.6.2
            Reporter: Howard Mak
            Assignee: Issue Review Board
         Attachments: readwrite_lock_test.zip, simple_lock_test.zip

ReentrantLock.isLocked() returns false [instead of true] if the lock is a DSO 
and is held by a thread.  This problem also occurs for ReentrantReadWriteLock's.

Reproduce case:
---------------

Attached are 2 reproduce cases [originally reported by 
http://forums.terracotta.org/forums/posts/list/0/1337.page].

Expected output [for both tests] is:
        test 1: [isLocked=true].isLocked() is ok 
        test 2: [isLocked=true].tryLock() is ok
But Terracotta generates:
        test 1: [isLocked=false].isLocked() is BAD! 
        test 2: [isLocked=false].tryLock() is ok

Possible workaround (not 100%):
-------------------------------

Use tryLock()/unlock() to emulate isLocked(), but this won't work if multiple 
threads do this simultaneous on a non-locked ReentrantLock.  Otherwise, avoid 
ReentrantLock altogether if isLocked() needs to be accurate.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
https://jira.terracotta.org/jira//secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        
_______________________________________________
tc-dev mailing list
tc-dev@lists.terracotta.org
http://lists.terracotta.org/mailman/listinfo/tc-dev

Reply via email to