OmniaGM commented on code in PR #19964:
URL: https://github.com/apache/kafka/pull/19964#discussion_r2161994977


##########
clients/src/main/java/org/apache/kafka/common/TopicIdPartition.java:
##########
@@ -78,6 +80,21 @@ public TopicPartition topicPartition() {
         return topicPartition;
     }
 
+    /**
+     * Checking if TopicIdPartition meant to be the same reference to same 
this object but doesn't have all the data.
+     * If topic name is empty and topic id is persisted then the method will 
rely on topic id only
+     * otherwise the method will rely on topic name.
+     * @return true if topic has same topicId and partition index as topic 
names some time might be empty.
+    */
+    public boolean same(TopicIdPartition tpId) {
+        if (Utils.isBlank(tpId.topic()) && 
!tpId.topicId.equals(Uuid.ZERO_UUID)) {
+            return topicId.equals(tpId.topicId) &&
+                    topicPartition.partition() == tpId.partition();
+        } else {
+            return topicPartition.equals(tpId.topicPartition());

Review Comment:
   > In the rare case that Sender::topicIdsForBatches returns 0 topic id (e.g. 
topic is deleted), we will pass along topicName -> 0 to 
handleProduceResponse(). The response will include empty topic and 0 topic id. 
It's important that we find a match in this case to avoid 
IllegalStateException. I am thinking that we should first try to do the 
comparison on topic name, if it's not empty. Otherwise, just do the comparison 
on topic id even if it's zero.
   
   Thinking out loud here shouldn't this be true for `TopicIdPartition::equals` 
as we might have this rare situation in other places in the code where topic id 
partition metadata wouldn't exist fully? Specially that right now not all Kafka 
a topic id aware yet. 



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