satishd commented on code in PR #15077:
URL: https://github.com/apache/kafka/pull/15077#discussion_r1437341409


##########
core/src/test/scala/unit/kafka/server/ReplicaManagerTest.scala:
##########
@@ -2704,28 +2710,30 @@ class ReplicaManagerTest {
       time = time,
       scheduler = time.scheduler,
       logManager = logManager,
-      quotaManagers = QuotaFactory.instantiate(config, metrics, time, ""),
+      quotaManagers = quotaManager,
       metadataCache = MetadataCache.zkMetadataCache(config.brokerId, 
config.interBrokerProtocolVersion),
       logDirFailureChannel = new LogDirFailureChannel(config.logDirs.size),
       alterPartitionManager = alterPartitionManager,
       threadNamePrefix = Option(this.getClass.getName))
 
-    logManager.startup(Set.empty[String])
-
-    // Create a hosted topic, a hosted topic that will become stray, and a 
stray topic
-    val validLogs = createHostedLogs("hosted-topic", numLogs = 2, 
replicaManager).toSet
-    createHostedLogs("hosted-stray", numLogs = 10, replicaManager).toSet
-    createStrayLogs(10, logManager)
+    try {
+      logManager.startup(Set.empty[String])
 
-    val allReplicasFromLISR = Set(new TopicPartition("hosted-topic", 0), new 
TopicPartition("hosted-topic", 1))
+      // Create a hosted topic, a hosted topic that will become stray, and a 
stray topic
+      val validLogs = createHostedLogs("hosted-topic", numLogs = 2, 
replicaManager).toSet
+      createHostedLogs("hosted-stray", numLogs = 10, replicaManager).toSet
+      createStrayLogs(10, logManager)
 
-    
replicaManager.updateStrayLogs(replicaManager.findStrayPartitionsFromLeaderAndIsr(allReplicasFromLISR))
+      val allReplicasFromLISR = Set(new TopicPartition("hosted-topic", 0), new 
TopicPartition("hosted-topic", 1))
 
-    assertEquals(validLogs, logManager.allLogs.toSet)
-    assertEquals(validLogs.size, replicaManager.partitionCount.value)
+      
replicaManager.updateStrayLogs(replicaManager.findStrayPartitionsFromLeaderAndIsr(allReplicasFromLISR))
 
-    replicaManager.shutdown()
-    logManager.shutdown()
+      assertEquals(validLogs, logManager.allLogs.toSet)
+      assertEquals(validLogs.size, replicaManager.partitionCount.value)
+    } finally {
+      replicaManager.shutdown()
+      logManager.shutdown()

Review Comment:
   Right @showuon , what I meant here was try closing the second one even if 
the earlier invocation has thrown an error to avoid leaks caused by not closing 
the second instance. We should not change any of the other places to swallow 
the exceptions where there is only one single invocation of shutting down of 
replicamanager or logmanager. 
   
   One way to do that is what @divijvaidya suggested. 



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