junrao commented on code in PR #23316:
URL: https://github.com/apache/kafka/pull/23316#discussion_r3979376078


##########
storage/src/test/java/org/apache/kafka/storage/internals/log/LocalLogTest.java:
##########
@@ -265,33 +265,43 @@ public void testLogCloseSuccess() throws IOException {
     }
 
     @Test
-    public void testLogCloseIdempotent() {
+    public void testCloseThrowsIfAlreadyClosed() {
         log.close();
-        // Check that LocalLog.close() is idempotent
+        assertThrows(KafkaStorageException.class, () -> log.close());
+    }
+
+    @Test
+    public void testCloseQuietlyThrowsIfAlreadyClosedQuietly() {
+        log.closeQuietly();
+        assertThrows(KafkaStorageException.class, () -> log.closeQuietly());
+    }
+
+    @Test
+    public void testCloseThrowsIfAlreadyClosedQuietly() {
         log.close();
+        assertThrows(KafkaStorageException.class, () -> log.closeQuietly());

Review Comment:
   It seems that this test should be named 
testCloseQuietlyThrowsIfAlreadyClosed and the next one should be 
testCloseThrowsIfAlreadyClosedQuietly.



##########
storage/src/main/java/org/apache/kafka/storage/internals/log/LocalLog.java:
##########
@@ -309,23 +309,29 @@ public void updateLogEndOffset(long endOffset) {
     }
 
     /**
-     * Close file handlers used by log but don't write to disk.
+     * Close the segments of the log, swallowing any exceptions from closing 
segments.
      * This is called if the log directory is offline.
+     *
+     * @throws KafkaStorageException if the log is already closed
      */
-    public void closeHandlers() {
-        segments.closeHandlers();
-        isMemoryMappedBufferClosed = true;
+    public void closeQuietly() {
+        checkIfClosed();

Review Comment:
   Thinking about it a bit more. It's probably safer to check the isClosed flag 
and just return if it's true instead of throwing. Ditto for close().



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