Fixed - RReadWriteLock.unlock() method doesn't respect the lock owner

pull/6394/head
Nikita Koksharov 2 weeks ago
parent 65f585fd0c
commit 1ce49b7a2e

@ -94,7 +94,7 @@ public class RedissonReadLock extends RedissonLock implements RLock {
"if (mode == false) then " +
"redis.call(ARGV[3], KEYS[2], ARGV[1]); " +
"redis.call('set', KEYS[5], 1, 'px', ARGV[4]); " +
"return 1; " +
"return nil; " +
"end; " +
"local lockExists = redis.call('hexists', KEYS[1], ARGV[2]); " +
"if (lockExists == 0) then " +

@ -87,7 +87,7 @@ public class RedissonWriteLock extends RedissonLock implements RLock {
"if (mode == false) then " +
"redis.call(ARGV[4], KEYS[2], ARGV[1]); " +
"redis.call('set', KEYS[3], 1, 'px', ARGV[5]); " +
"return 1; " +
"return nil; " +
"end;" +
"if (mode == 'write') then " +
"local lockExists = redis.call('hexists', KEYS[1], ARGV[3]); " +

@ -16,8 +16,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.*;
import static org.awaitility.Awaitility.await;
public class RedissonReadWriteLockTest extends BaseConcurrentTest {
@ -439,6 +438,7 @@ public class RedissonReadWriteLockTest extends BaseConcurrentTest {
for (int i = 0; i < 5; i++) {
assertThat(rwlock.readLock().remainTimeToLive()).isGreaterThan(19000);
assertThat(rwlock.writeLock().remainTimeToLive()).isGreaterThan(19000);
TimeUnit.SECONDS.sleep(5);
}
@ -493,10 +493,11 @@ public class RedissonReadWriteLockTest extends BaseConcurrentTest {
t.start();
t.join();
lock.writeLock().unlock();
assertThatThrownBy(() -> {
lock.writeLock().unlock();
}).isInstanceOf(IllegalMonitorStateException.class);
}
@Test
public void testAutoExpire() throws InterruptedException {
testSingleInstanceConcurrency(1, r -> {

Loading…
Cancel
Save