gaurav-narula commented on code in PR #16042:
URL: https://github.com/apache/kafka/pull/16042#discussion_r1611804316


##########
core/src/test/scala/unit/kafka/server/ReplicaManagerTest.scala:
##########
@@ -6594,6 +6594,64 @@ class ReplicaManagerTest {
       ))
     }
   }
+
+  @Test
+  def testReplicaManagerDontGenerateEmptyTopicPartition(): Unit = {

Review Comment:
   It might be easier to test this in `DescribeLogDirsRequestTest` by setting 
up 2 topics with 2 topic partitions each and querying for both partitions of 
either one of the topics.



##########
core/src/main/scala/kafka/server/ReplicaManager.scala:
##########
@@ -1247,7 +1247,8 @@ class ReplicaManager(val config: KafkaConfig,
         val usableBytes = adjustForLargeFileSystems(fileStore.getUsableSpace)
         logsByDir.get(absolutePath) match {
           case Some(logs) =>
-            val topicInfos = logs.groupBy(_.topicPartition.topic).map{case 
(topic, logs) =>
+            val topicInfos = logs.filter(_.topicPartition.topic.nonEmpty)

Review Comment:
   I don't think the bug is due to `UnifiedLog.topicPartition.topic` being 
empty but rather because we don't filter for logs which pertain to the topics 
in the argument to the function.
   
   Consider the case where the `logs` refers to logs for `["topicA-0", 
"topicA-1", "topicB-0", "topicB-1"]` and `partitions` is `["topicA-0", 
"topicA-1"]`



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to