Skip to content

Commit 6804c03

Browse files
committed
GH-10471: pass unLockChannelKey as KEYS[2] instead of ARGV[2] as values used as keys should be passed as such
Signed-off-by: Severin Kistler <[email protected]>
1 parent a578e0d commit 6804c03

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.util.ConcurrentModificationException;
2424
import java.util.Date;
2525
import java.util.LinkedHashMap;
26+
import java.util.List;
2627
import java.util.Map;
2728
import java.util.Map.Entry;
2829
import java.util.UUID;
@@ -668,7 +669,7 @@ private final class RedisPubSubLock extends RedisLock {
668669
private static final String UNLINK_UNLOCK_SCRIPT = """
669670
local lockClientId = redis.call('GET', KEYS[1])
670671
if (lockClientId == ARGV[1] and redis.call('UNLINK', KEYS[1]) == 1) then
671-
redis.call('PUBLISH', ARGV[2], KEYS[1])
672+
redis.call('PUBLISH', KEYS[2], KEYS[1])
672673
return true
673674
end
674675
return false
@@ -689,9 +690,10 @@ protected boolean tryRedisLockInner(long time, long expireAfter)
689690

690691
@Override
691692
protected boolean removeLockKeyInnerUnlink() {
693+
final String unLockChannelKey = RedisLockRegistry.this.unLockChannelKey + ":" + this.lockKey;
692694
return Boolean.TRUE.equals(RedisLockRegistry.this.redisTemplate.execute(
693-
UNLINK_UNLOCK_REDIS_SCRIPT, Collections.singletonList(this.lockKey),
694-
RedisLockRegistry.this.clientId, RedisLockRegistry.this.unLockChannelKey + ":" + this.lockKey));
695+
UNLINK_UNLOCK_REDIS_SCRIPT, List.of(this.lockKey, unLockChannelKey),
696+
RedisLockRegistry.this.clientId));
695697
}
696698

697699
private boolean subscribeLock(long time, long expireAfter) throws ExecutionException, InterruptedException {

0 commit comments

Comments
 (0)