Skip to content

Commit 2d75289

Browse files
committed
Fix UNLINK/DEL logic in the RedisLockRegistry
See review: #3691 (comment)
1 parent 50fa345 commit 2d75289

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

spring-integration-redis/src/main/java/org/springframework/integration/redis/util/RedisLockRegistry.java

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -438,27 +438,29 @@ public void unlock() {
438438
}
439439

440440
private void removeLockKey() {
441-
try {
442-
if (RedisLockRegistry.this.unlinkAvailable) {
441+
if (RedisLockRegistry.this.unlinkAvailable) {
442+
try {
443443
RedisLockRegistry.this.redisTemplate.execute(
444444
RedisLockRegistry.this.unLinkUnLockScript, Collections.singletonList(this.lockKey),
445445
RedisLockRegistry.this.unLockChannelKey);
446+
return;
446447
}
447-
}
448-
catch (Exception ex) {
449-
RedisLockRegistry.this.unlinkAvailable = false;
450-
if (LOGGER.isDebugEnabled()) {
451-
LOGGER.debug("The UNLINK command has failed (not supported on the Redis server?); " +
452-
"falling back to the regular DELETE command", ex);
453-
}
454-
else {
455-
LOGGER.warn("The UNLINK command has failed (not supported on the Redis server?); " +
456-
"falling back to the regular DELETE command: " + ex.getMessage());
448+
catch (Exception ex) {
449+
RedisLockRegistry.this.unlinkAvailable = false;
450+
if (LOGGER.isDebugEnabled()) {
451+
LOGGER.debug("The UNLINK command has failed (not supported on the Redis server?); " +
452+
"falling back to the regular DELETE command", ex);
453+
}
454+
else {
455+
LOGGER.warn("The UNLINK command has failed (not supported on the Redis server?); " +
456+
"falling back to the regular DELETE command: " + ex.getMessage());
457+
}
457458
}
458-
RedisLockRegistry.this.redisTemplate.execute(
459-
RedisLockRegistry.this.deleteUnLockScript, Collections.singletonList(this.lockKey),
460-
RedisLockRegistry.this.unLockChannelKey);
461459
}
460+
461+
RedisLockRegistry.this.redisTemplate.execute(
462+
RedisLockRegistry.this.deleteUnLockScript, Collections.singletonList(this.lockKey),
463+
RedisLockRegistry.this.unLockChannelKey);
462464
}
463465

464466
@Override

0 commit comments

Comments
 (0)