FrankYang0529 commented on code in PR #15568:
URL: https://github.com/apache/kafka/pull/15568#discussion_r1537361217


##########
core/src/test/scala/unit/kafka/log/LogManagerTest.scala:
##########
@@ -1303,6 +1303,29 @@ class LogManagerTest {
         createLeaderAndIsrRequestForStrayDetection(present),
         onDisk.map(mockLog(_))).toSet)
   }
+
+  /**
+   * Test LogManager takes file lock by default and the lock is released after 
shutdown.
+   */
+  @Test
+  def testLock(): Unit = {
+    val tmpLogDir = TestUtils.tempDir()
+    val tmpLogManager = createLogManager(Seq(tmpLogDir))
+
+    // ${tmpLogDir}.lock is acquired by tmpLogManager
+    val fileLock = new FileLock(new File(tmpLogDir, LogManager.LockFileName))
+    try {
+      assertFalse(fileLock.tryLock())
+    } finally {
+      // ${tmpLogDir}.lock is removed after shutdown
+      tmpLogManager.shutdown()
+      val f = new File(tmpLogDir, LogManager.LockFileName)
+      assertFalse(f.exists())
+
+      fileLock.destroy()

Review Comment:
   Originally, I would like to double confirm the file is removed, but I don't 
think we need it now, because the file should be removed by 
`LogManager#shutdown`.



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