cadonna commented on code in PR #14532:
URL: https://github.com/apache/kafka/pull/14532#discussion_r1360369521


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/NetworkClientDelegate.java:
##########
@@ -254,28 +250,34 @@ public String toString() {
         }
     }
 
-    public static class FutureCompletionHandler implements 
RequestCompletionHandler {
-
-        private final CompletableFuture<ClientResponse> future;
+    public static class FutureCompletionHandler extends 
CompletableFuture<ClientResponse> implements RequestCompletionHandler {

Review Comment:
   Why do you want to inherit from `CompletableFuture`? Extending base classes 
might lead to the fragile base class problem. I do not see that your code 
manifests this problem at the moment, but I think it would be better to 
minimize the surface for such problem if possible and if it does not cost too 
much.  



##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/HeartbeatRequestManager.java:
##########
@@ -184,13 +184,11 @@ private NetworkClientDelegate.UnsentRequest 
makeHeartbeatRequest() {
         NetworkClientDelegate.UnsentRequest request = new 
NetworkClientDelegate.UnsentRequest(
             new ConsumerGroupHeartbeatRequest.Builder(data),
             coordinatorRequestManager.coordinator());
-        request.future().whenComplete((response, exception) -> {
+        request.handler().whenComplete((response, exception) -> {
             if (response != null) {
                 onResponse((ConsumerGroupHeartbeatResponse) 
response.responseBody(), response.receivedTimeMs());
             } else {
-                // TODO: Currently, we lack a good way to propage the response 
time from the network client to the
-                //  request handler. We will need to store the response time 
in the handler to make it accessible.
-                onFailure(exception, time.milliseconds());
+                onFailure(exception, request.handler().completionTimeMs());

Review Comment:
   I am not sure, I understand. If `onComplete()` is never called with response 
== `null` why is there a branch in the completion handler for that case that 
calls `onFailure()`? Wouldn't it be better to throw an `IllegalStateException` 
or similar? 



-- 
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