I'd like to port libraries to Java 8. At the moment I have blocking http operations, and the caller needs to care about this problem.
When I port my library to java 8, I am thinking of changing the method signatures not to return just Response, but instead to return CompletableFuture<Response>. For this to be possible the constructor of my main library class would need to take a third argument: An Executor or ExecutorService, so they have control about pool sizes, shutdown() etc.
I have seen many tutorials which discuess how CompletableFuture<?> works, but none of them is dealing with the question whether a libary should return those objects or let the caller deal with async "problems".
Another disadvantage might be, that I need to wrap my exceptions in a CompletionException.
Please help me decide which strategy is best: blocking operations and let the user decide, or just return a CompletableFuture<>.
Thanks.
