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/07/08 12:58:57 UTC

[GitHub] [kafka] showuon commented on a change in pull request #10952: KAFKA-12257: Consumer mishandles topics deleted and recreated with the same name

showuon commented on a change in pull request #10952:
URL: https://github.com/apache/kafka/pull/10952#discussion_r666157068



##########
File path: clients/src/main/java/org/apache/kafka/clients/Metadata.java
##########
@@ -367,7 +386,8 @@ else if (metadata.error() == Errors.TOPIC_AUTHORIZATION_FAILED)
      */
     private Optional<MetadataResponse.PartitionMetadata> updateLatestMetadata(

Review comment:
       We should also update the java doc to mention the TopicId changed case

##########
File path: clients/src/main/java/org/apache/kafka/clients/MetadataCache.java
##########
@@ -130,13 +149,30 @@ MetadataCache mergeWith(String newClusterId,
                             Set<String> addInvalidTopics,
                             Set<String> addInternalTopics,
                             Node newController,
+                            Map<String, Uuid> topicIds,
                             BiPredicate<String, Boolean> retainTopic) {
 
         Predicate<String> shouldRetainTopic = topic -> retainTopic.test(topic, internalTopics.contains(topic));
 
         Map<TopicPartition, PartitionMetadata> newMetadataByPartition = new HashMap<>(addPartitions.size());
+        Map<String, Uuid> newTopicIds = new HashMap<>(topicIds.size());
+
+        // We want the most recent topic ID. We add the old one here for retained topics and then update with newest information in the MetadataResponse
+        // we add if a new topic ID is added or remove if the request did not support topic IDs for this topic.

Review comment:
       Can't get what you mean here. Could you rephrase this sentence?

##########
File path: clients/src/main/java/org/apache/kafka/clients/Metadata.java
##########
@@ -216,6 +217,14 @@ public synchronized boolean updateRequested() {
         }
     }
 
+    public synchronized Uuid topicId(String topicName) {
+        return cache.topicId(topicName);
+    }
+
+    public synchronized  String topicName(Uuid topicId) {

Review comment:
       nit: 2 spaces between `synchronized` and `String`




-- 
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-unsubscribe@kafka.apache.org

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