Skip to content
Open
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 @@ -268,7 +268,7 @@ Optional<Lock> createNewLock(Lock lock) {
.withLockPeriodDuration(lockPeriod.toString());
return Try.of(() -> mongoTemplate.insert(toAcquire, lockCollectionName))
.onSuccess(acquired -> log.debug("New lock created and acquired: {}", acquired))
.onFailure(throwable -> log.error("New lock creation error: {}", throwable::getMessage))
.onFailure(throwable -> log.error("New lock creation error: {}", throwable.getMessage()))
.toJavaOptional();
}

Expand Down Expand Up @@ -299,8 +299,9 @@ Optional<Lock> acquireExistingLock(Lock lock) {
.apply(Update.update("state", Lock.State.LOCKED).set("lastModifiedAt", Instant.now()))
.findAndModify()
)
.onSuccess(o -> log.debug(o.map(unused -> "Existing lock acquired").orElse("Wasn't able to acquire existing lock")))
.onFailure(throwable -> log.error("Error occurred on acquiring of existing lock: {}", throwable::getMessage))
.onSuccess(o -> log.debug(o.map(aLock -> String.format("Existing lock %s acquired", aLock))
.orElse("Wasn't able to acquire existing lock")))
.onFailure(throwable -> log.error("Error occurred on acquiring of existing lock: {}", throwable.getMessage()))
.getOrElseThrow(throwable -> new LockException(throwable));
}

Expand All @@ -314,7 +315,7 @@ Optional<Lock> acquireExistingLock(Lock lock) {
<T> Optional<T> executeAndRelease(Lock lock, CheckedFunction0<T> execution) {
return Try.of(execution)
.andFinallyTry(() -> release(lock.id))
.onFailure(throwable -> log.error("Execution error: {}", throwable::getMessage))
.onFailure(throwable -> log.error("Execution error: {}", throwable.getMessage()))
.onSuccess(result -> log.debug("Execution result: {}", result))
.toJavaOptional();
}
Expand All @@ -329,7 +330,7 @@ <T> Optional<T> executeAndRelease(Lock lock, CheckedFunction0<T> execution) {
Optional<Boolean> runAndRelease(Lock lock, CheckedRunnable runnable) {
return Try.run(runnable)
.andFinallyTry(() -> release(lock.id))
.onFailure(throwable -> log.error("Run error: {}", throwable::getMessage))
.onFailure(throwable -> log.error("Run error: {}", throwable.getMessage()))
.map(unused -> true)
.recover(throwable -> false)
.toJavaOptional();
Expand Down