chia7712 commented on code in PR #17409:
URL: https://github.com/apache/kafka/pull/17409#discussion_r1807288476


##########
clients/src/main/java/org/apache/kafka/common/internals/KafkaFutureImpl.java:
##########
@@ -252,6 +252,9 @@ public String toString() {
         } catch (Exception e) {

Review Comment:
   we should handle `CancellationException` first
   ```java
           try {
               value = completableFuture.getNow(null);
           } catch (CancellationException e) {
               if (e.getCause() instanceof CancellationException) {
                   exception = e.getCause();
               } else exception = e;
           } catch (CompletionException e) {
               exception = e.getCause();
           } catch (Exception e) {
               exception = e;
           }
   ```



##########
clients/src/main/java/org/apache/kafka/common/internals/KafkaFutureImpl.java:
##########
@@ -180,7 +180,7 @@ public T get(long timeout, TimeUnit unit) throws 
InterruptedException, Execution
             return completableFuture.get(timeout, unit);
         } catch (ExecutionException e) {

Review Comment:
   we should unwrap the `CancellationException` for java 23.
   ```java
       public T get() throws InterruptedException, ExecutionException {
           try {
               return completableFuture.get();
           } catch (ExecutionException | CancellationException e) {
               maybeThrowCancellationException(e.getCause());
               throw e;
           }
       }
   ```



##########
clients/src/main/java/org/apache/kafka/common/internals/KafkaFutureImpl.java:
##########
@@ -165,7 +165,7 @@ public T get() throws InterruptedException, 
ExecutionException {
             return completableFuture.get();
         } catch (ExecutionException e) {
             maybeThrowCancellationException(e.getCause());
-            throw e;

Review Comment:
   ditto
   ```java
           try {
               return completableFuture.get();
           } catch (ExecutionException | CancellationException e) {
               maybeThrowCancellationException(e.getCause());
               throw e;
           }
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to