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 9bd8001a61)
This commit is contained in:
Roman Zabaluev
2023-12-12 05:06:21 +07:00
committed by Artem Bilan
parent 8c18dc553a
commit ec707e71fa

View File

@@ -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() {