@ Deprecated public static < V > CompletableFuture < V > unmodifiableFuture ( CompletableFuture < V > future , boolean propagateCancel ) { requireNonNull ( future , "future is null" ) ; Function < Boolean , Boolean > onCancelFunction ; if ( propagateCancel ) { onCancelFunction = future :: cancel ; } else { onCancelFunction = mayInterrupt -> false ; } UnmodifiableCompletableFuture < V > unmodifiableFuture = new UnmodifiableCompletableFuture <> ( onCancelFunction ) ; future . whenComplete ( ( value , exception ) -> { if ( exception != null ) { unmodifiableFuture . internalCompleteExceptionally ( exception ) ; } else { unmodifiableFuture . internalComplete ( value ) ; } } ) ; return unmodifiableFuture ; }
Returns a future that can not be completed or optionally canceled .