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



##########
File path: core/src/main/scala/kafka/cluster/Partition.scala
##########
@@ -428,6 +428,35 @@ class Partition(val topicPartition: TopicPartition,
       this.log = Some(log)
   }
 
+  /**
+   * This method checks if the topic ID provided in the request is consistent 
with the topic ID in the log.
+   * If a valid topic ID is provided, but the log has no ID set, set the log 
ID to be the request ID.
+   * Returns a boolean representing whether the topic ID was consistent and 
the final log ID if it exists.
+   */
+  def checkOrSetTopicId(requestTopicId: Uuid): (Boolean, Option[Uuid]) = {
+    // If the request had an invalid topic ID, then we assume that topic IDs 
are not supported.
+    // The topic ID was not inconsistent, so return true.
+    // If the log is empty, then we can not say that topic ID is inconsistent, 
so return true.
+    if (requestTopicId == null || requestTopicId == Uuid.ZERO_UUID)
+      (true, None)
+    else if (log.isEmpty)

Review comment:
       I had that in the back of my head but couldn't quite remember. Thanks 
for reminding. :)




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