jolshan commented on a change in pull request #10282: URL: https://github.com/apache/kafka/pull/10282#discussion_r597999822
########## File path: core/src/main/scala/kafka/server/ReplicaManager.scala ########## @@ -1473,6 +1484,30 @@ class ReplicaManager(val config: KafkaConfig, } } + /** + * Checks if the topic ID provided in the LeaderAndIsr request is consistent with the topic ID in the log. + * + * If the request had an invalid topic ID (null or zero), then we assume that topic IDs are not supported. + * The topic ID was not inconsistent, so return true. + * If the log does not exist or the topic ID is not yet set, logTopicIdOpt will be None. + * In both cases, the ID is not inconsistent so return true. + * + * @param requestTopicId the topic ID from the LeaderAndIsr request + * @param logTopicIdOpt the topic ID in the log if the log and the topic ID exist + * @return true if the request topic id is consistent, false otherwise + */ + private def checkTopicId(requestTopicId: Uuid, logTopicIdOpt: Option[Uuid]): Boolean = { + if (requestTopicId == null || requestTopicId == Uuid.ZERO_UUID) { + true + } else + logTopicIdOpt match { Review comment: I've changed the match portion to `logTopicIdOpt.isEmpty || logTopicIdOpt.contains(requestTopicId)` -- 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