OmniaGM commented on code in PR #14881: URL: https://github.com/apache/kafka/pull/14881#discussion_r1415618371
########## core/src/main/scala/kafka/server/ReplicaManager.scala: ########## @@ -2643,6 +2645,17 @@ class ReplicaManager(val config: KafkaConfig, } } + private def getAssignedDirectoryId(delta: TopicsDelta, partition: Partition): Option[Uuid] = { + for { + (topicId, topicDelta) <- delta.changedTopics().asScala.find(_._2.name() == partition.topic) + if topicDelta != null + partitionRegistration = topicDelta.partitionChanges().get(partition.partitionId) + if partitionRegistration != null + localBrokerIndexInReplicas = partitionRegistration.replicas.indexOf(localBrokerId) + directory = partitionRegistration.directories(localBrokerIndexInReplicas) + } yield directory + } + Review Comment: I updated this to ` Option(newImage.topics().getPartition(topicId, partitionId)).map(_.directory(localBrokerId))` as `TopicsImage.getPartition` has the potential of returning `null` and wrapping `.getPartition(topicId, partitionId).directory` in `Option` would not protect us from `NullPointerException`. One other thing to keep in mind here is `PartitionRegistration.directory` may throw `IllegalArgumentException` which shouldn't be a concern in real use cases but can cause misconfigure tests to fail with `IllegalArgumentException` -- 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