merlimat commented on pull request #12744:
URL: https://github.com/apache/pulsar/pull/12744#issuecomment-973114794


   @liangyepianzhou @congbobo184 I think the PR solves the problem but it has a 
regression. 
   
   The `exceptionally()` clause is also use to catch exceptions that are being 
thrown in the `whenComplete()` part. For example we have a `checkNotNull(...)` 
part there.
   
   Instead, I'd suggest to keep the exceptionally() part and convert the 
`whenComplete()` into `thenAccept()`.
   
   Eg:
   
   ```java
   CompletableFuture<Void> f;
   
   doSomething()
       .thenAccept(res -> {
            //// Potentially throw exception
           f.complete(..);
       }).exceptionally(ex -> {
           f.completeExceptionally(ex);
          return null;
       });
   ```
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to