Hangleton commented on code in PR #13240:
URL: https://github.com/apache/kafka/pull/13240#discussion_r1122830477


##########
clients/src/main/java/org/apache/kafka/common/requests/OffsetCommitResponse.java:
##########
@@ -119,43 +128,53 @@ public boolean shouldClientThrottle(short version) {
         return version >= 4;
     }
 
-    public static class Builder {
-        OffsetCommitResponseData data = new OffsetCommitResponseData();
-        HashMap<String, OffsetCommitResponseTopic> byTopicName = new 
HashMap<>();
+    public short version() {
+        return version;
+    }
 
-        private OffsetCommitResponseTopic getOrCreateTopic(
-            String topicName
-        ) {
-            OffsetCommitResponseTopic topic = byTopicName.get(topicName);
-            if (topic == null) {
-                topic = new OffsetCommitResponseTopic().setName(topicName);
-                data.topics().add(topic);
-                byTopicName.put(topicName, topic);
-            }
-            return topic;
+    public static Builder<?> newBuilder(TopicResolver topicResolver, short 
version) {
+        if (version >= 9) {
+            return new Builder<>(topicResolver, new ByTopicId(), version);
+        } else {
+            return new Builder<>(topicResolver, new ByTopicName(), version);
         }
+    }
 
-        public Builder addPartition(
-            String topicName,
-            int partitionIndex,
-            Errors error
-        ) {
-            final OffsetCommitResponseTopic topicResponse = 
getOrCreateTopic(topicName);
+    public static final class Builder<T> {
+        private final TopicResolver topicResolver;
+        private final TopicClassifier<T> topicClassifier;

Review Comment:
   Thinking about it, it seems unnecessary to adopt a different classification 
for v >= 9 since topic names should always be resolved when calling 
`addPartition`. Will remove all this logic and simplify.



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