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);
        (info, ex) -> {
            if (ex == null) { 
                // do something with info
            } else {
                // handle exception
  • 2
    \$\begingroup\$ i^m not sure if this question is suitable here, see codereview.stackexchange.com/help/how-to-ask: "Do not ask questions about broken code, hypothetical code, or non-existent code, as such questions will be closed as off-topic." \$\endgroup\$ Aug 5, 2022 at 7:38


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.