Skip to content

Commit f687438

Browse files
mhyeon-leeartembilan
authored andcommitted
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`** # Conflicts: # spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/lock/JdbcLockRegistry.java
1 parent a4cadc9 commit f687438

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2022 the original author or authors.
2+
* Copyright 2016-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -54,6 +54,7 @@
5454
* @author Olivier Hubaut
5555
* @author Fran Aranda
5656
* @author Unseok Kim
57+
* @author Myeonghyeon Lee
5758
*
5859
* @since 4.3
5960
*/
@@ -310,7 +311,7 @@ public Condition newCondition() {
310311
}
311312

312313
public boolean isAcquiredInThisProcess() {
313-
return this.mutex.isAcquired(this.path);
314+
return delegate.isLocked();
314315
}
315316

316317
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
@@ -83,6 +83,7 @@
8383
* @author Unseok Kim
8484
* @author Anton Gabov
8585
* @author Eddie Cho
86+
* @author Myeonghyeon Lee
8687
*
8788
* @since 4.0
8889
*
@@ -503,8 +504,7 @@ public final Condition newCondition() {
503504
}
504505

505506
public final boolean isAcquiredInThisProcess() {
506-
return RedisLockRegistry.this.clientId.equals(
507-
RedisLockRegistry.this.redisTemplate.boundValueOps(this.lockKey).get());
507+
return this.localLock.isLocked();
508508
}
509509

510510
@Override

0 commit comments

Comments
 (0)