I want a CompletableFuture that only signals the completion (e.g. I don't have a return value).
I can instantiate the CompletableFuture as:
CompletableFuture<Void> future = new CompletableFuture<> ();
But what should I feed into the complete method? For example, I can't do
future.complete(new Void());
As you've noticed, you cannot instantiate a Void
object like this.
Since you don't care about the future's value, you could just complete it with null
:
future.complete(null);