jolshan commented on a change in pull request #9944:
URL: https://github.com/apache/kafka/pull/9944#discussion_r627027261



##########
File path: 
clients/src/main/java/org/apache/kafka/common/requests/FetchRequest.java
##########
@@ -319,12 +355,25 @@ public int maxBytes() {
         return data.maxBytes();
     }
 
-    public Map<TopicPartition, PartitionData> fetchData() {
-        return fetchData;
+    // For versions 13+, throws UnknownTopicIdException if the topic ID was 
unknown to the server.
+    public Map<TopicPartition, PartitionData> fetchData(Map<Uuid, String> 
topicNames) throws UnknownTopicIdException {
+        if (version() < 13)
+            return fetchData;
+        return toPartitionDataMap(data.topics(), topicNames);
     }
 
-    public List<TopicPartition> toForget() {
-        return toForget;
+    // For versions 13+, throws UnknownTopicIdException if the topic ID was 
unknown to the server.
+    public List<FetchRequestData.ForgottenTopic> forgottenTopics(Map<Uuid, 
String> topicNames) throws UnknownTopicIdException {
+        if (version() >= 13) {
+            data.forgottenTopicsData().forEach(forgottenTopic -> {
+                String name = topicNames.get(forgottenTopic.topicId());
+                if (name == null) {
+                    throw new UnknownTopicIdException(String.format("Topic Id 
%s in FetchRequest was unknown to the server", forgottenTopic.topicId()));
+                }
+                
forgottenTopic.setTopic(topicNames.getOrDefault(forgottenTopic.topicId(), ""));

Review comment:
       I originally did this when dealing with unresolved partitions. I was 
wondering if it would be better to not create a second data structure. If 
creating another structure (as done before) is not a problem, we can go back to 
that.




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


Reply via email to