Description
I'm wondering why FutureConverters.toJava
creates a new CompletableFuture
, rather than simply wrapping the Future
with an implementation of CompletionStage
that delegates to Future
? Doing this would make conversion a little more efficient, and would mean conversions back and forth could be optimised so a conversion from a previously converted CompletionStage
to Future
would simply unwrap the Future
.
The latter especially will be useful in Play, since we want to allow both Java and Scala code to intercept requests, and mixing these interceptors will potentially mean lots of conversions back and forth between the types. If it's just a simple wrapping/unwrapping, then we don't need to worry about the cost associated with it, otherwise we may end up with long chains of Futures and CompletionStages that add nothing to the actual value except overhead.