skaundinya15 commented on a change in pull request #10962: URL: https://github.com/apache/kafka/pull/10962#discussion_r663421298
########## File path: clients/src/main/java/org/apache/kafka/common/requests/OffsetFetchResponse.java ########## @@ -185,21 +271,42 @@ public boolean hasError() { return error != Errors.NONE; } + public boolean groupHasError(String groupId) { + return groupLevelErrors.get(groupId) != Errors.NONE; + } + public Errors error() { return error; } + public Errors groupLevelError(String groupId) { + return groupLevelErrors.get(groupId); + } + @Override public Map<Errors, Integer> errorCounts() { Map<Errors, Integer> counts = new HashMap<>(); - updateErrorCounts(counts, error); - data.topics().forEach(topic -> - topic.partitions().forEach(partition -> + if (!groupLevelErrors.isEmpty()) { + // built response with v8 or above + for (Map.Entry<String, Errors> entry : groupLevelErrors.entrySet()) { + updateErrorCounts(counts, entry.getValue()); + } + for (OffsetFetchResponseGroup group : data.groupIds()) { + group.topics().forEach(topic -> + topic.partitions().forEach(partition -> updateErrorCounts(counts, Errors.forCode(partition.errorCode())))); + } + } else { + // built response with v0-v7 + updateErrorCounts(counts, error); + data.topics().forEach(topic -> + topic.partitions().forEach(partition -> + updateErrorCounts(counts, Errors.forCode(partition.errorCode())))); + } return counts; } - public Map<TopicPartition, PartitionData> responseData() { + public Map<TopicPartition, PartitionData> oldResponseData() { Review comment: Good point, I will rename this method to reflect which versions this applies to and add a comment that it is only public for testing, as I will refactor everything else that uses this to use `responseData()` since we are moving the version checks into that method. -- 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