Skip to content

Commit

Permalink
Rename global lock's key from /lock/exclusive/locks to /lock/global/l…
Browse files Browse the repository at this point in the history
…ocks (#34142)
  • Loading branch information
terrymanu authored Dec 24, 2024
1 parent 91d84ad commit f4c1815
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
@Getter
public final class GlobalLockDefinition implements LockDefinition {

private static final String KEY_PATTERN = "/lock/exclusive/locks/%s";
private static final String KEY_PATTERN = "/lock/global/locks/%s";

private final String lockKey;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ class GlobalLockDefinitionTest {
void assertGetLockKey() {
GlobalLock globalLock = mock(GlobalLock.class);
when(globalLock.getName()).thenReturn("foo_lock");
assertThat(new GlobalLockDefinition(globalLock).getLockKey(), is("/lock/exclusive/locks/foo_lock"));
assertThat(new GlobalLockDefinition(globalLock).getLockKey(), is("/lock/global/locks/foo_lock"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void setUp() {

@Test
void assertTryLock() {
when(repository.getDistributedLockHolder().getDistributedLock("/lock/exclusive/locks/foo_lock").tryLock(1000L)).thenReturn(true);
when(repository.getDistributedLockHolder().getDistributedLock("/lock/global/locks/foo_lock").tryLock(1000L)).thenReturn(true);
GlobalLockDefinition lockDefinition = new GlobalLockDefinition(globalLock);
assertTrue(new GlobalLockPersistService(repository).tryLock(lockDefinition, 1000L));
}
Expand All @@ -56,6 +56,6 @@ void assertTryLock() {
void assertUnlock() {
GlobalLockDefinition lockDefinition = new GlobalLockDefinition(globalLock);
new GlobalLockPersistService(repository).unlock(lockDefinition);
verify(repository.getDistributedLockHolder().getDistributedLock("/lock/exclusive/locks/foo_lock")).unlock();
verify(repository.getDistributedLockHolder().getDistributedLock("/lock/global/locks/foo_lock")).unlock();
}
}

0 comments on commit f4c1815

Please sign in to comment.