DefaultLockRepository: Use == 1 for delete and renew query results

Some claim that it might improve code readability.
This commit is contained in:
Eddie Cho
2024-10-30 21:01:04 +01:00
committed by GitHub
parent b50c40279a
commit bab7e8d579

View File

@@ -392,7 +392,7 @@ public class DefaultLockRepository
@Override
public boolean delete(String lock) {
return this.defaultTransactionTemplate.execute(
transactionStatus -> this.template.update(this.deleteQuery, this.region, lock, this.id)) > 0;
transactionStatus -> this.template.update(this.deleteQuery, this.region, lock, this.id)) == 1;
}
@Override
@@ -436,7 +436,7 @@ public class DefaultLockRepository
public boolean renew(String lock) {
final Boolean result = this.defaultTransactionTemplate.execute(
transactionStatus ->
this.template.update(this.renewQuery, epochMillis(), this.region, lock, this.id) > 0);
this.template.update(this.renewQuery, epochMillis(), this.region, lock, this.id) == 1);
return Boolean.TRUE.equals(result);
}