From 9bd8001a61fbbe2f87c8c283e32f57619961def5 Mon Sep 17 00:00:00 2001 From: Roman Zabaluev Date: Tue, 12 Dec 2023 05:06:21 +0700 Subject: [PATCH] GH-8803: RedisLockRegistry: Log for lock acquired Fixes: #8803 Would be great to have an `Acquired lock; RedisLock...` logging message as we already have `Released lock; RedisLock ...` * Improve `RedisLockRegistry.RedisLock.tryRedisLock()` to emit `Acquired lock; RedisLock...` debug message **Cherry-pick to `6.0.x`** --- .../integration/redis/util/RedisLockRegistry.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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 d0fa41ba26..729b855fb2 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 @@ -85,6 +85,7 @@ import org.springframework.util.ReflectionUtils; * @author Christian Tzolov * @author Eddie Cho * @author Myeonghyeon Lee + * @author Roman Zabaluev * * @since 4.0 * @@ -432,11 +433,14 @@ public final class RedisLockRegistry implements ExpirableLockRegistry, Disposabl } private boolean tryRedisLock(long time) throws ExecutionException, InterruptedException { - final boolean result = tryRedisLockInner(time); - if (result) { + final boolean acquired = tryRedisLockInner(time); + if (acquired) { + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Acquired lock; " + this); + } this.lockedAt = System.currentTimeMillis(); } - return result; + return acquired; } protected final Boolean obtainLock() {