diff --git a/spring-integration-redis/src/main/java/org/springframework/integration/redis/util/RedisLockRegistry.java b/spring-integration-redis/src/main/java/org/springframework/integration/redis/util/RedisLockRegistry.java index 172f4d5eb9..df2fb6e209 100644 --- a/spring-integration-redis/src/main/java/org/springframework/integration/redis/util/RedisLockRegistry.java +++ b/spring-integration-redis/src/main/java/org/springframework/integration/redis/util/RedisLockRegistry.java @@ -464,13 +464,10 @@ public final class RedisLockRegistry implements ExpirableLockRegistry, Disposabl private void removeLockKey() { if (RedisLockRegistry.this.unlinkAvailable) { + Boolean unlinkResult = null; try { - boolean unlinkResult = removeLockKeyInnerUnlink(); - if (!unlinkResult) { - throw new IllegalStateException("Lock was released in the store due to expiration. " + - "The integrity of data protected by this lock may have been compromised."); - } - return; + // Attempt to UNLINK the lock key; an exception indicates lack of UNLINK support + unlinkResult = removeLockKeyInnerUnlink(); } catch (Exception ex) { RedisLockRegistry.this.unlinkAvailable = false; @@ -483,6 +480,15 @@ public final class RedisLockRegistry implements ExpirableLockRegistry, Disposabl "falling back to the regular DELETE command: " + ex.getMessage()); } } + + if (Boolean.TRUE.equals(unlinkResult)) { + // Lock key successfully unlinked + return; + } + else if (Boolean.FALSE.equals(unlinkResult)) { + throw new IllegalStateException("Lock was released in the store due to expiration. " + + "The integrity of data protected by this lock may have been compromised."); + } } if (!removeLockKeyInnerDelete()) { throw new IllegalStateException("Lock was released in the store due to expiration. " +