You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2021/03/03 07:54:10 UTC

[GitHub] [kafka] dajac commented on a change in pull request #10234: MINOR; Clean up LeaderAndIsrResponse construction in `ReplicaManager#becomeLeaderOrFollower`

dajac commented on a change in pull request #10234:
URL: https://github.com/apache/kafka/pull/10234#discussion_r586188217



##########
File path: clients/src/main/java/org/apache/kafka/common/requests/LeaderAndIsrRequest.java
##########
@@ -145,24 +145,22 @@ public LeaderAndIsrResponse getErrorResponse(int throttleTimeMs, Throwable e) {
                         .setErrorCode(error.code()));
             }
             responseData.setPartitionErrors(partitions);
-            return new LeaderAndIsrResponse(responseData, version());
-        }
-
-        List<LeaderAndIsrTopicError> topics = new ArrayList<>(data.topicStates().size());
-        Map<String, Uuid> topicIds = topicIds();
-        for (LeaderAndIsrTopicState topicState : data.topicStates()) {
-            LeaderAndIsrTopicError topicError = new LeaderAndIsrTopicError();
-            topicError.setTopicId(topicIds.get(topicState.topicName()));
-            List<LeaderAndIsrPartitionError> partitions = new ArrayList<>(topicState.partitionStates().size());
-            for (LeaderAndIsrPartitionState partition : topicState.partitionStates()) {
-                partitions.add(new LeaderAndIsrPartitionError()
+        } else {
+            Map<String, Uuid> topicIds = topicIds();
+            for (LeaderAndIsrTopicState topicState : data.topicStates()) {
+                List<LeaderAndIsrPartitionError> partitions = new ArrayList<>(
+                    topicState.partitionStates().size());
+                for (LeaderAndIsrPartitionState partition : topicState.partitionStates()) {
+                    partitions.add(new LeaderAndIsrPartitionError()
                         .setPartitionIndex(partition.partitionIndex())
                         .setErrorCode(error.code()));
+                }
+                responseData.topics().add(new LeaderAndIsrTopicError()
+                    .setTopicId(topicIds.get(topicState.topicName()))

Review comment:
       Good catch. I missed this one.




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

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