kirktrue commented on code in PR #14680:
URL: https://github.com/apache/kafka/pull/14680#discussion_r1378071781


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/PrototypeAsyncConsumer.java:
##########
@@ -384,12 +384,10 @@ public void commitAsync(Map<TopicPartition, 
OffsetAndMetadata> offsets, OffsetCo
         final OffsetCommitCallback commitCallback = callback == null ? new 
DefaultOffsetCommitCallback() : callback;
         future.whenComplete((r, t) -> {
             if (t != null) {
-                commitCallback.onComplete(offsets, new KafkaException(t));
+                commitCallback.onComplete(offsets, (Exception) t);
             } else {
                 commitCallback.onComplete(offsets, null);
             }
-        }).exceptionally(e -> {
-            throw new KafkaException(e);

Review Comment:
   I had a question about this code (even from before this change)—On which 
thread will the user's callback be executed?
   
   I'm pretty sure that the event's `Future` is completed on the background 
thread, right? If so, that means that the callback passed to `whenComplete` is 
going to be completed on the background thread. And since it then calls the 
user's callback, it will also be called on the background thread.
   
   Thoughts?



##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/PrototypeAsyncConsumer.java:
##########
@@ -384,12 +384,10 @@ public void commitAsync(Map<TopicPartition, 
OffsetAndMetadata> offsets, OffsetCo
         final OffsetCommitCallback commitCallback = callback == null ? new 
DefaultOffsetCommitCallback() : callback;
         future.whenComplete((r, t) -> {
             if (t != null) {
-                commitCallback.onComplete(offsets, new KafkaException(t));
+                commitCallback.onComplete(offsets, (Exception) t);
             } else {
                 commitCallback.onComplete(offsets, null);
             }
-        }).exceptionally(e -> {
-            throw new KafkaException(e);

Review Comment:
   I had a question about this code (even from before this change)—On which 
thread will the user's callback be executed?
   
   I'm pretty sure that the event's `Future` is completed on the background 
thread, right? If so, that means that the callback passed to `whenComplete` is 
going to be completed on the background thread. And since it then calls the 
user's callback, it will also be called on the background thread.
   
   Thoughts?



-- 
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: jira-unsubscr...@kafka.apache.org

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

Reply via email to