Merge branch 'master' of github.com:redisson/redisson

pull/3848/head
Nikita Koksharov 4 years ago
commit 36ac00dde6

@ -174,7 +174,13 @@ public abstract class RedissonBaseLock extends RedissonExpirable implements RLoc
oldEntry.addThreadId(threadId);
} else {
entry.addThreadId(threadId);
renewExpiration();
try {
renewExpiration();
} finally {
if (Thread.currentThread().isInterrupted()) {
cancelExpirationRenewal(threadId);
}
}
}
}

@ -112,6 +112,7 @@ public class CommandAsyncService implements CommandAsyncExecutor {
try {
future.await();
} catch (InterruptedException e) {
future.cancel(true);
Thread.currentThread().interrupt();
throw new RedisException(e);
}

@ -111,6 +111,29 @@ public class RedissonLockTest extends BaseConcurrentTest {
runner.stop();
}
@Test
public void testLockIsNotRenewedAfterInterruptedTryLock() throws InterruptedException {
final CountDownLatch countDownLatch = new CountDownLatch(1);
RLock lock = redisson.getLock("myLock");
assertThat(lock.isLocked()).isFalse();
Thread thread = new Thread(() -> {
countDownLatch.countDown();
if (!lock.tryLock()) {
return;
}
lock.unlock();
});
thread.start();
countDownLatch.await();
// let the tcp request be sent out
TimeUnit.MILLISECONDS.sleep(5);
thread.interrupt();
TimeUnit.SECONDS.sleep(45);
assertThat(lock.isLocked()).isFalse();
}
@Test
public void testRedisFailed() {
Assertions.assertThrows(WriteRedisConnectionException.class, () -> {

Loading…
Cancel
Save