From ec707e71fadd3380e312af09390caf64f222ce4f 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`** (cherry picked from commit 9bd8001a61fbbe2f87c8c283e32f57619961def5) --- .../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 713c2f17cf..df7ac58b46 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 @@ -84,6 +84,7 @@ import org.springframework.util.ReflectionUtils; * @author Anton Gabov * @author Eddie Cho * @author Myeonghyeon Lee + * @author Roman Zabaluev * * @since 4.0 * @@ -421,11 +422,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() {