Skip to content

Commit 2cf0742

Browse files
committed
Workaround for scala/scala3#13549
1 parent 53cb88b commit 2cf0742

File tree

1 file changed

+48
-12
lines changed

1 file changed

+48
-12
lines changed

core/src/test/scala/unit/kafka/log/LocalLogTest.scala

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -485,14 +485,20 @@ class LocalLogTest {
485485
@Test
486486
def testParseTopicPartitionNameForEmptyName(): Unit = {
487487
val dir = new File("")
488-
assertThrows(classOf[KafkaException], () => LocalLog.parseTopicPartitionName(dir),
488+
assertThrows(classOf[KafkaException], () => {
489+
LocalLog.parseTopicPartitionName(dir)
490+
()
491+
},
489492
() => "KafkaException should have been thrown for dir: " + dir.getCanonicalPath)
490493
}
491494

492495
@Test
493496
def testParseTopicPartitionNameForNull(): Unit = {
494497
val dir: File = null
495-
assertThrows(classOf[KafkaException], () => LocalLog.parseTopicPartitionName(dir),
498+
assertThrows(classOf[KafkaException], () => {
499+
LocalLog.parseTopicPartitionName(dir)
500+
()
501+
},
496502
() => "KafkaException should have been thrown for dir: " + dir)
497503
}
498504

@@ -501,11 +507,17 @@ class LocalLogTest {
501507
val topic = "test_topic"
502508
val partition = "1999"
503509
val dir = new File(logDir, topic + partition)
504-
assertThrows(classOf[KafkaException], () => LocalLog.parseTopicPartitionName(dir),
510+
assertThrows(classOf[KafkaException], () => {
511+
LocalLog.parseTopicPartitionName(dir)
512+
()
513+
},
505514
() => "KafkaException should have been thrown for dir: " + dir.getCanonicalPath)
506515
// also test the "-delete" marker case
507516
val deleteMarkerDir = new File(logDir, topic + partition + "." + LocalLog.DeleteDirSuffix)
508-
assertThrows(classOf[KafkaException], () => LocalLog.parseTopicPartitionName(deleteMarkerDir),
517+
assertThrows(classOf[KafkaException], () => {
518+
LocalLog.parseTopicPartitionName(deleteMarkerDir)
519+
()
520+
},
509521
() => "KafkaException should have been thrown for dir: " + deleteMarkerDir.getCanonicalPath)
510522
}
511523

@@ -514,13 +526,19 @@ class LocalLogTest {
514526
val topic = ""
515527
val partition = "1999"
516528
val dir = new File(logDir, topicPartitionName(topic, partition))
517-
assertThrows(classOf[KafkaException], () => LocalLog.parseTopicPartitionName(dir),
529+
assertThrows(classOf[KafkaException], () => {
530+
LocalLog.parseTopicPartitionName(dir)
531+
()
532+
},
518533
() => "KafkaException should have been thrown for dir: " + dir.getCanonicalPath)
519534

520535
// also test the "-delete" marker case
521536
val deleteMarkerDir = new File(logDir, LocalLog.logDeleteDirName(new TopicPartition(topic, partition.toInt)))
522537

523-
assertThrows(classOf[KafkaException], () => LocalLog.parseTopicPartitionName(deleteMarkerDir),
538+
assertThrows(classOf[KafkaException], () => {
539+
LocalLog.parseTopicPartitionName(deleteMarkerDir)
540+
()
541+
},
524542
() => "KafkaException should have been thrown for dir: " + deleteMarkerDir.getCanonicalPath)
525543
}
526544

@@ -529,12 +547,18 @@ class LocalLogTest {
529547
val topic = "test_topic"
530548
val partition = ""
531549
val dir = new File(logDir.getPath + topicPartitionName(topic, partition))
532-
assertThrows(classOf[KafkaException], () => LocalLog.parseTopicPartitionName(dir),
550+
assertThrows(classOf[KafkaException], () => {
551+
LocalLog.parseTopicPartitionName(dir)
552+
()
553+
},
533554
() => "KafkaException should have been thrown for dir: " + dir.getCanonicalPath)
534555

535556
// also test the "-delete" marker case
536557
val deleteMarkerDir = new File(logDir, topicPartitionName(topic, partition) + "." + LocalLog.DeleteDirSuffix)
537-
assertThrows(classOf[KafkaException], () => LocalLog.parseTopicPartitionName(deleteMarkerDir),
558+
assertThrows(classOf[KafkaException], () => {
559+
LocalLog.parseTopicPartitionName(deleteMarkerDir)
560+
()
561+
},
538562
() => "KafkaException should have been thrown for dir: " + deleteMarkerDir.getCanonicalPath)
539563
}
540564

@@ -543,22 +567,34 @@ class LocalLogTest {
543567
val topic = "test_topic"
544568
val partition = "1999a"
545569
val dir = new File(logDir, topicPartitionName(topic, partition))
546-
assertThrows(classOf[KafkaException], () => LocalLog.parseTopicPartitionName(dir),
570+
assertThrows(classOf[KafkaException], () => {
571+
LocalLog.parseTopicPartitionName(dir)
572+
()
573+
},
547574
() => "KafkaException should have been thrown for dir: " + dir.getCanonicalPath)
548575

549576
// also test the "-delete" marker case
550577
val deleteMarkerDir = new File(logDir, topic + partition + "." + LocalLog.DeleteDirSuffix)
551-
assertThrows(classOf[KafkaException], () => LocalLog.parseTopicPartitionName(deleteMarkerDir),
578+
assertThrows(classOf[KafkaException], () => {
579+
LocalLog.parseTopicPartitionName(deleteMarkerDir)
580+
()
581+
},
552582
() => "KafkaException should have been thrown for dir: " + deleteMarkerDir.getCanonicalPath)
553583
}
554584

555585
@Test
556586
def testParseTopicPartitionNameForExistingInvalidDir(): Unit = {
557587
val dir1 = new File(logDir.getPath + "/non_kafka_dir")
558-
assertThrows(classOf[KafkaException], () => LocalLog.parseTopicPartitionName(dir1),
588+
assertThrows(classOf[KafkaException], () => {
589+
LocalLog.parseTopicPartitionName(dir1)
590+
()
591+
},
559592
() => "KafkaException should have been thrown for dir: " + dir1.getCanonicalPath)
560593
val dir2 = new File(logDir.getPath + "/non_kafka_dir-delete")
561-
assertThrows(classOf[KafkaException], () => LocalLog.parseTopicPartitionName(dir2),
594+
assertThrows(classOf[KafkaException], () => {
595+
LocalLog.parseTopicPartitionName(dir2)
596+
()
597+
},
562598
() => "KafkaException should have been thrown for dir: " + dir2.getCanonicalPath)
563599
}
564600

0 commit comments

Comments
 (0)