GH-9401: RedisLockRegistry: use lock() instead of tryLock() for lifecycle

Fixes: #9401

Switched `tryLock()` with `lock()` in `RedisLockRegistry.runRedisMessageListenerContainer()` method for correct synchronization.

**Auto-cherry-pick to `6.3.x` & `6.2.x`**
This commit is contained in:
alexpeelman
2024-08-20 18:08:48 +02:00
committed by GitHub
parent feef055a53
commit 07085a17ae

View File

@@ -87,6 +87,7 @@ import org.springframework.util.ReflectionUtils;
* @author Eddie Cho
* @author Myeonghyeon Lee
* @author Roman Zabaluev
* @author Alex Peelman
*
* @since 4.0
*
@@ -658,7 +659,7 @@ public final class RedisLockRegistry implements ExpirableLockRegistry, Disposabl
}
private void runRedisMessageListenerContainer() {
RedisLockRegistry.this.lock.tryLock();
RedisLockRegistry.this.lock.lock();
try {
if (!(RedisLockRegistry.this.isRunningRedisMessageListenerContainer
&& RedisLockRegistry.this.redisMessageListenerContainer != null