unlocking of nested readLock deletes writeLock. #891

pull/903/head
Nikita 8 years ago
parent aac6de5a61
commit 48ddec70e2

@ -117,6 +117,10 @@ public class RedissonReadLock extends RedissonLock implements RLock {
"redis.call('pexpire', KEYS[1], maxRemainTime); " +
"return 0; " +
"end;" +
"if mode == 'write' then " +
"return 0;" +
"end; " +
"end; " +
"redis.call('del', KEYS[1]); " +

@ -95,6 +95,22 @@ public class RedissonReadWriteLockTest extends BaseConcurrentTest {
Assert.assertTrue(writeLock.tryLock());
}
@Test
public void testWR() throws InterruptedException {
RReadWriteLock rw = redisson.getReadWriteLock("my_read_write_lock");
RLock writeLock = rw.writeLock();
writeLock.lock();
rw.readLock().lock();
assertThat(writeLock.isLocked()).isTrue();
rw.readLock().unlock();
assertThat(writeLock.isLocked()).isTrue();
writeLock.unlock();
assertThat(writeLock.isLocked()).isFalse();
}
@Test
public void testWriteReadReentrancy() throws InterruptedException {
RReadWriteLock readWriteLock = redisson.getReadWriteLock("TEST");

Loading…
Cancel
Save