CompletionStage

Doug Lea dl at cs.oswego.edu
Mon Jul 1 03:32:58 PDT 2013


On 06/30/13 17:00, Sam Pullara wrote:
> On Sun, Jun 30, 2013 at 1:34 PM, Doug Lea <dl at cs.oswego.edu
>     They can (re)throw any exception they like when completed exceptionally.
>
>
> This is really ugly.

Thanks again for spotting this problem. Adding
onExceptionalCompletion to cope, which pretty
much forces adding onNormalCompletion for symmetry:


     /**
      * Returns a new CompletionStage with the same result
      * or exception as this stage, and when this stage completes,
      * executes the given action only if this stage
      * completes exceptionally. This would be equivalent in effect to
      * {@code exceptionally(ex -> { action.accept(ex); throw ex})}
      * if this were expressible without type check errors.
      *
      * @param action the action to perform if this CompletionStage
      * completed exceptionally
      */
     public CompletionStage<T> onExceptionalCompletion
         (Consumer<? super Throwable> action);

     /**
      * Returns a new CompletionStage with the same result
      * or exception as this stage, and when this stage completes,
      * executes the given action only if this stage
      * completes normally. This is equivalent in effect to
      * {@code thenApply(x -> { action.accept(x); return x})}.
      *
      * @param action the action to perform if this CompletionStage
      * completed normally
      */
     public CompletionStage<T> onNormalCompletion
         (Consumer<? super T> action);



More information about the lambda-libs-spec-experts mailing list