I'm curious to the behavior of a CompletableFuture, that has been set to a different Executor, when it goes out of scope of the method that supplied it.
Say, for instance, that the following code fragment is being used:
public List<String> someMethod(ExecutorService service){
List<String> myData = this.getMyData();
CompletableFuture.supplyAsync(() -> this.doSomethingWithMyData(myData), service)
.thenApplyAsync(this::doSomeTransformation)
.thenAcceptAsync(this::consumeResults)
.orTimeout(5, TimeUnit.MINUTES);
return myData;
}
Assuming this is long running concurrent job,, would the CompletableFuture (and it's chain of async functions) still get completely executed after the method returns? This is assuming the overall application is still running in that timeframe (a RESTful service, for example).
My gut tells me that it would still run after the method returns, but I haven't seen the answer to this, so I'm hoping for some validation of that guess.