Replace Futures.successfulAsList with Java 8 CompletableFuture?
问题 I am Looking for canonical code to replace Guava's Futures.successfulAsList() with Java 8's CompletableFuture code. I think CompletableFuture.allOf() seems like a replacement for Futures.allAsList(), but I don't see anything quite like successfulAsList() . 回答1: CompletableFuture.allOf(…) is actually closer to successfulAsList() than allAsList() . Indeed, allOf() only completes after all the given futures have completed, be it with a value or an exception. You can then inspect each future to