Skip to content

Commit 50c53e0

Browse files
authored
GH-8730: Fix isAcquiredInThisProcess to use localLock
The `ExpirableLockRegistry.expireUnusedOlderThan()` uses a query to the target store by mistake. The logic of this API is indeed about the local cache for those lock instances. We cannot effect any other processes with this cache. And even if we remove our local instance while it is locked in other process, that doesn't mean that on the next `obtain()` call, when we got a fresh local instance, we will be able to acquire a lock in target store. * Fix `isAcquiredInThisProcess()` to check only `localLock.isLocked()` **Cherry-pick to `6.1.x` & `6.0.x`**
1 parent 78367f2 commit 50c53e0

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/lock/JdbcLockRegistry.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
* @author Fran Aranda
5656
* @author Unseok Kim
5757
* @author Christian Tzolov
58+
* @author Myeonghyeon Lee
5859
*
5960
* @since 4.3
6061
*/
@@ -326,7 +327,7 @@ public Condition newCondition() {
326327
}
327328

328329
public boolean isAcquiredInThisProcess() {
329-
return this.mutex.isAcquired(this.path);
330+
return delegate.isLocked();
330331
}
331332

332333
public boolean renew() {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
* @author Anton Gabov
8585
* @author Christian Tzolov
8686
* @author Eddie Cho
87+
* @author Myeonghyeon Lee
8788
*
8889
* @since 4.0
8990
*
@@ -514,8 +515,7 @@ public final Condition newCondition() {
514515
}
515516

516517
public final boolean isAcquiredInThisProcess() {
517-
return RedisLockRegistry.this.clientId.equals(
518-
RedisLockRegistry.this.redisTemplate.boundValueOps(this.lockKey).get());
518+
return this.localLock.isLocked();
519519
}
520520

521521
@Override

0 commit comments

Comments
 (0)