public static < T > CompletableFuture < T > orderedFuture ( CompletableFuture < T > future ) { CompletableFuture < T > newFuture = new OrderedFuture <> ( ) ; future . whenComplete ( ( r , e ) -> { if ( e == null ) { newFuture . complete ( r ) ; } else { newFuture . completeExceptionally ( e ) ; } } ) ; return newFuture ; }
Returns a future that completes callbacks in add order .