Skip to content

Commit 9d17e37

Browse files
authored
Make JdbcLockRegistry.pathFor protected to allow overriding
Signed-off-by: Steffen Nießing <[email protected]>
1 parent ddd105d commit 9d17e37

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public DistributedLock obtain(Object lockKey) {
151151
}
152152
}
153153

154-
private String pathFor(String input) {
154+
protected String pathFor(String input) {
155155
return UUIDConverter.getUUID(input).toString();
156156
}
157157

spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/lock/JdbcLockRegistryTests.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,26 @@ void testUnlockAfterLockStatusHasBeenExpiredAndDeleted() throws Exception {
613613
.isThrownBy(lock::unlock);
614614
}
615615

616+
@Test
617+
void testPathForCanBeOverridden() {
618+
DefaultLockRepository client = new DefaultLockRepository(dataSource);
619+
client.setApplicationContext(this.context);
620+
client.afterPropertiesSet();
621+
client.afterSingletonsInstantiated();
622+
JdbcLockRegistry registry = new JdbcLockRegistry(client) {
623+
@Override
624+
protected String pathFor(String input) {
625+
return input;
626+
}
627+
};
628+
629+
final String lockKey = "foo";
630+
Lock lock = registry.obtain(lockKey);
631+
String lockPath = TestUtils.getPropertyValue(lock, "path", String.class);
632+
633+
assertThat(lockPath).isEqualTo(lockKey);
634+
}
635+
616636
@SuppressWarnings("unchecked")
617637
private static Map<String, Lock> getRegistryLocks(JdbcLockRegistry registry) {
618638
return TestUtils.getPropertyValue(registry, "locks", Map.class);

0 commit comments

Comments
 (0)