CompletableFuture vs ListenableFuture

1,422 views
Skip to first unread message

carmi....@gmail.com

unread,
Nov 2, 2018, 2:28:04 PM11/2/18
to guava-discuss
Hi Guava team!
I was wondering if there’s a recommendation to use either CF or LF in new code.
Are there clear advantages to either API over the other? Are there any issues in one API or the other that you’re aware of?
Thanks!

Jonathan Bluett-Duncan

unread,
Nov 4, 2018, 11:32:43 AM11/4/18
to carmi....@gmail.com, guava-...@googlegroups.com
I'd be interested to hear the Guava team's thoughts on this as well. :)

Cheers,
Jonathan

--
guava-...@googlegroups.com
Project site: https://github.com/google/guava
This group: http://groups.google.com/group/guava-discuss

This list is for general discussion.
To report an issue: https://github.com/google/guava/issues/new
To get help: http://stackoverflow.com/questions/ask?tags=guava
---
You received this message because you are subscribed to the Google Groups "guava-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to guava-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/guava-discuss/b02f5010-c5cf-41ae-813d-d5979b94141c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Timothy Peierls

unread,
Nov 4, 2018, 6:56:57 PM11/4/18
to guava-discuss
The question should really be about CompletableFuture vs FluentFuture, as these are roughly analogous constructs. Here's what the FluentFuture docs say:

Users of CompletableFuture will likely want to continue using CompletableFuture. FluentFuture is targeted at people who use ListenableFuture, who can't use Java 8, or who want an API more focused than CompletableFuture. (If you need to adapt between CompletableFuture and ListenableFuture, consider FutureConverter.)

Afaik, the only feature of FluentFuture that is not supported by Java 8 CompletableFuture is withTimeout. Java 9+ CompletableFuture does have something equivalent to withTimeout.

If you already use ListenableFuture, or you rely on an API that does, or you are stuck on Java 7, or you feel that FluentFuture is truly "more focused" than CompletableFuture, then go ahead, otherwise I would stick to CompletableFuture.

I would strongly recommend against exposing ListenableFuture or FluentFuture in new APIs, because you'll be saddling users of that API with an extra dependency for no very good reason.

--tim

Kevin Bourrillion

unread,
Nov 5, 2018, 3:34:04 PM11/5/18
to Tim Peierls, guava-...@googlegroups.com
I'm going to see if I can expand the FluentFuture/ListenableFuture javadocs to try to lay out the trade-offs between them and CompletableFuture a little more comprehensively.


--
guava-...@googlegroups.com
Project site: https://github.com/google/guava
This group: http://groups.google.com/group/guava-discuss
 
This list is for general discussion.
To report an issue: https://github.com/google/guava/issues/new
To get help: http://stackoverflow.com/questions/ask?tags=guava
---
You received this message because you are subscribed to the Google Groups "guava-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to guava-discus...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
Kevin Bourrillion | Java Librarian | Google, Inc. | kev...@google.com
Reply all
Reply to author
Forward
0 new messages