Can someone review whether this code I have written makes sense? playing around with completableFutures
i have a DAO implementation which should return a CompletableFuture
public CompletableFuture<List<Info>> readFromDremio(Request request) {
return CompletableFuture.supplyAsync(
() -> dremioReferenceDAO.getData(req.date, req.nameList));
}
Then I want to take the result of the future and do some processing on it
public void handleResponse(Request request){
CompletableFuture<List<Info>> infoFuture = dataHandler.readFromDremio(request);
infoFuture.whenComplete(
(info, ex) -> {
if (ex == null) {
// do something with info
} else {
// handle exception
}
)
return;
}