jolshan commented on a change in pull request #9944: URL: https://github.com/apache/kafka/pull/9944#discussion_r593283525
########## File path: clients/src/main/java/org/apache/kafka/common/requests/FetchResponse.java ########## @@ -80,15 +156,34 @@ public Errors error() { return Errors.forCode(data.errorCode()); } - public LinkedHashMap<TopicPartition, FetchResponseData.PartitionData> responseData() { + public LinkedHashMap<TopicPartition, FetchResponseData.PartitionData> responseData(Map<Uuid, String> topicNames, short version) { + if (version < 13) + return toResponseDataMap(); + return toResponseDataMap(topicNames); + + } + + // TODO: Should be replaced or cleaned up. The idea is that in KafkaApis we need to reconstruct responseData even though we could have just passed in and out a map. + // With topic IDs, recreating the map takes a little more time since we have to get the topic name from the topic ID to name map. + // The refactor somewhat helps in KafkaApis, but we have to recompute the map instead of just returning it. + // This is unsafe in test cases now (FetchSessionTest) where it used to be safe. Before it would just pull the responseData map. + // If we wanted to recompute with topicNames we could call responseData(topicNames) however, + // now it will just return the version computed here. + + // Used when we can guarantee responseData is populated with all possible partitions + // This occurs when we have a response version < 13 or we built the FetchResponse with + // responseDataMap as a parameter and we have the same topic IDs available. + public LinkedHashMap<TopicPartition, FetchResponseData.PartitionData> resolvedResponseData() { Review comment: Got it. I think the issue here then is that some of the information can not be auto-generated data. We need topic names for certain methods but names will not be in the auto-generated data. ---------------------------------------------------------------- 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: us...@infra.apache.org