Skip to content

Commit 5458750

Browse files
committed
refactor(distributed-lock): Minor refactoring to avoid deprecated calls
1 parent 5140bda commit 5458750

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

distributed-lock-core/src/main/java/com/github/alturkovic/lock/AbstractSimpleLock.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,19 @@ public String acquire(final List<String> keys, final String storeId, final long
4646
throw new IllegalStateException("Cannot lock with empty token");
4747
}
4848

49-
return acquire(keys.get(0), storeId, token, expiration);
49+
return acquire(keys.getFirst(), storeId, token, expiration);
5050
}
5151

5252
@Override
5353
public boolean release(final List<String> keys, final String storeId, final String token) {
5454
Assert.isTrue(keys.size() == 1, "Cannot release lock for multiple keys with this lock");
55-
return release(keys.get(0), storeId, token);
55+
return release(keys.getFirst(), storeId, token);
5656
}
5757

5858
@Override
5959
public boolean refresh(final List<String> keys, final String storeId, final String token, final long expiration) {
6060
Assert.isTrue(keys.size() == 1, "Cannot refresh lock for multiple keys with this lock");
61-
return refresh(keys.get(0), storeId, token, expiration);
61+
return refresh(keys.getFirst(), storeId, token, expiration);
6262
}
6363

6464
protected abstract String acquire(String key, String storeId, String token, long expiration);

distributed-lock-core/src/main/java/com/github/alturkovic/lock/key/SpelKeyGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public List<String> resolveKeys(final String lockKeyPrefix, final String express
6060
throw new EvaluationConvertException("null keys are not supported: " + keys);
6161
}
6262

63-
if (StringUtils.isEmpty(lockKeyPrefix)) {
63+
if (!StringUtils.hasText(lockKeyPrefix)) {
6464
return keys;
6565
}
6666

distributed-lock-core/src/main/java/com/github/alturkovic/lock/retry/RetriableLock.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public String acquire(final List<String> keys, final String storeId, final long
4646
return retryTemplate.execute(ctx -> {
4747
final String token = lock.acquire(keys, storeId, expiration);
4848

49-
if (StringUtils.isEmpty(token)) {
49+
if (!StringUtils.hasText(token)) {
5050
throw new LockNotAvailableException(String.format("Lock not available for keys: %s in store %s", keys, storeId));
5151
}
5252

0 commit comments

Comments
 (0)