Use exceptionally instead of handle in SQLDB

The wrong method was in use for error handling completable future
This commit is contained in:
Risto Lahtela 2021-04-23 09:01:59 +03:00
parent bd7336b411
commit 9ccbda0ebd

View File

@ -47,7 +47,7 @@ import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.*;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Supplier;
/**
@ -261,11 +261,11 @@ public abstract class SQLDB extends AbstractDatabase {
accessLock.checkAccess(transaction);
transaction.executeTransaction(this);
return CompletableFuture.completedFuture(null);
}, getTransactionExecutor()).handle(errorHandler(transaction, origin));
}, getTransactionExecutor()).exceptionally(errorHandler(transaction, origin));
}
private BiFunction<CompletableFuture<Object>, Throwable, CompletableFuture<Object>> errorHandler(Transaction transaction, Exception origin) {
return (obj, throwable) -> {
private Function<Throwable, CompletableFuture<Object>> errorHandler(Transaction transaction, Exception origin) {
return throwable -> {
if (throwable == null) {
return CompletableFuture.completedFuture(null);
}