I have 3 different methods in my application. All are returning CompletableFuture<SomeType>
. I want to execute method 1 and 2 in parallel. On completion of method 1 and 2, I want to trigger method 3 with parameters from method 1 and 2 return values.
Code example :
CompletableFuture<Request> future1 = RequestConverter.Convert(requestDto);
CompletableFuture<String> future2 = tokenProvider.getAuthToken();
CompletableFuture<CompletableFuture<String>> future3 =
future1.thenCombine(future2,(request,token) ->
requestProcessor.Process(request,token));
But the problem with the above code is that I am getting a CompletableFuture
of CompletableFuture
. I want to avoid this and get a simple CompletableFuture<String>
without blocking. Is this possible?