showuon commented on code in PR #14051:
URL: https://github.com/apache/kafka/pull/14051#discussion_r1268862349


##########
core/src/main/scala/kafka/cluster/Partition.scala:
##########
@@ -998,7 +998,13 @@ class Partition(val topicPartition: TopicPartition,
       // 3. Its metadata cached broker epoch matches its Fetch request broker 
epoch. Or the Fetch
       //    request broker epoch is -1 which bypasses the epoch verification.
       case kRaftMetadataCache: KRaftMetadataCache =>
-        val storedBrokerEpoch = 
remoteReplicasMap.get(followerReplicaId).stateSnapshot.brokerEpoch
+        val mayBeReplica = getReplica(followerReplicaId)
+        // The topic is already deleted and we don't have any replica 
information. In this case, we can return false
+        // so as to avoid NPE
+        if (mayBeReplica.isEmpty) {
+          return false

Review Comment:
   We should log something here. maybe:
   `warn(s"The replica state of replica ID:[$followerReplicaId] doesn't exist 
in the leader node. It might because the topic is already deleted.")`
   WDYT?



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