Skip to content

Commit 99bddaf

Browse files
committed
improve test
1 parent da9905f commit 99bddaf

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

storage/src/test/java/org/apache/kafka/storage/internals/log/UnifiedLogTest.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import org.apache.kafka.common.Uuid;
2020
import org.apache.kafka.common.compress.Compression;
21-
import org.apache.kafka.common.errors.KafkaStorageException;
2221
import org.apache.kafka.common.record.ControlRecordType;
2322
import org.apache.kafka.common.record.MemoryRecords;
2423
import org.apache.kafka.common.record.RecordBatch;
@@ -65,13 +64,7 @@ public class UnifiedLogTest {
6564
public void tearDown() throws IOException {
6665
brokerTopicStats.close();
6766
for (UnifiedLog log : logsToClose) {
68-
try {
69-
// some test like testLogDeletionAfterClose and testLogDeletionAfterClose
70-
// they are closed from test so KafkaStorageException is expected.
71-
log.close();
72-
} catch (KafkaStorageException ignore) {
73-
// ignore
74-
}
67+
log.close();
7568
}
7669
Utils.delete(tmpDir);
7770
}
@@ -448,6 +441,8 @@ public void testLogDeletionAfterClose() throws IOException {
448441
.withRetentionMs(999)
449442
.build();
450443
log = createLog(logDir, logConfig);
444+
// avoid close after test because it is closed in this test
445+
logsToClose.remove(log);
451446

452447
// append some messages to create some segments
453448
log.appendAsLeader(records.get(), 0);
@@ -470,6 +465,8 @@ public void testDeleteOldSegments() throws IOException {
470465
.withRetentionMs(999)
471466
.build();
472467
log = createLog(logDir, logConfig);
468+
// avoid close after test because it is closed in this test
469+
logsToClose.remove(log);
473470

474471
// append some messages to create some segments
475472
for (int i = 0; i < 100; i++) {

0 commit comments

Comments
 (0)