Closed johanburatti closed 8 years ago
@@ master #40 diff @@
========================================
Files 4 4
Lines 61 54 -7
Methods 0 0
Messages 0 0
Branches 3 3
========================================
- Hits 61 54 -7
Misses 0 0
Partials 0 0
Powered by Codecov. Last updated by 61233d8...d180917
👍
Thinking about it some more, I might actually prefer to not encourage successfulAsList
in Java8 and rather do something like:
Stream.of(a, b)
.map(this::someAsyncFunction)
.map(fallbackTo(null))
.collect(joinList())
This makes it more obvious at the call site that you introduce null
values in the result. Any strong opinions @dflemstr @spkrka?
I haven't though about it a whole lot, but my gut feeling agrees with you. Alternatively we could have successfulAsList(defaultValue, futures)
or successfulAsList(t -> toValue(t), futures)
- then it would also be more obvious how failures are converted to values instead of always returning null
I think the points you make are very valid. When migrating from ListanebleFuture we only duplicated that behavior, which I agree is not optimal.
Personally I think I like the suggestion of @spkrka with a lambda since that is still much more convenient to type and easier to understand when reading than the stream-based one. @mbruggmann if you agree, I will change successfulAsList to require a function from throwable to value as well.
Updated after comments
👍 for the implementation. Only nitpick left: Should this really be successfulAsList
now or rather an overload of allAsList
?
Regarding naming it allAsList
now, I disagree. I think it is different enough to be named something else. Also, successfulAsList
is what the corresponding guava method is called.
Sorry about the delay... Updated PR with rebased change. Added javadoc for
I think this is good to merge now. @dflemstr @spkrka any last minute concerns?
No strong opinions from me
When migrating from guava ListenableFuture, we missed the Futures.successfulAsList. This implements the same functionality for CompletableFutures.