ReentrantReadWriteLock fails to get lock even when its state is Unlocked
<p>I am trying to get lock on a thread using following piece of code:</p>

<pre><code>Lock lock = readLock ? getLock(key).readLock() : getLock(key).writeLock();
try {
    boolean locked = lock.tryLock(DEFAULT_TRY_TIME, DEFAULT_TRY_TIME_UNIT); //line 3
    // If false, lock is not acquired
    if (!locked) {
        throw new TryLockTimeoutException(
                key + ": Failed to acquire " + lock + " within " + DEFAULT_TRY_TIME_STRING);
    }
}
</code></pre>

<p>Line 3 returns false after 30 minutes hence <code>TryLockTimeoutException</code> is thrown with error as:</p>

<pre><code>com.concurrent.TryLockTimeoutException: keyIp : Failed to acquire java.util.concurrent.locks.ReentrantReadWriteLock$WriteLock@74be2cee[Unlocked] within 30MINUTES
    at com.concurrent.NeAccessLockMap.acquireReadOrWriteLock(NeAccessLockMap.java:72)
</code></pre>

<p>Notice that lock state is shown as Unlocked in error.</p>

<p>I am not able to understand why would this happen? Why thread is not able to get lock even when the lock is free.</p>