Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public DistributedLock obtain(Object lockKey) {
}
}

private String pathFor(String input) {
protected String pathFor(String input) {
return UUIDConverter.getUUID(input).toString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,26 @@ void testUnlockAfterLockStatusHasBeenExpiredAndDeleted() throws Exception {
.isThrownBy(lock::unlock);
}

@Test
void testPathForCanBeOverridden() {
DefaultLockRepository client = new DefaultLockRepository(dataSource);
client.setApplicationContext(this.context);
client.afterPropertiesSet();
client.afterSingletonsInstantiated();
JdbcLockRegistry registry = new JdbcLockRegistry(client) {
@Override
protected String pathFor(String input) {
return input;
}
};

final String lockKey = "foo";
Lock lock = registry.obtain(lockKey);
String lockPath = TestUtils.getPropertyValue(lock, "path", String.class);

assertThat(lockPath).isEqualTo(lockKey);
}

@SuppressWarnings("unchecked")
private static Map<String, Lock> getRegistryLocks(JdbcLockRegistry registry) {
return TestUtils.getPropertyValue(registry, "locks", Map.class);
Expand Down