@@ -485,14 +485,20 @@ class LocalLogTest {
485
485
@ Test
486
486
def testParseTopicPartitionNameForEmptyName (): Unit = {
487
487
val dir = new File (" " )
488
- assertThrows(classOf [KafkaException ], () => LocalLog .parseTopicPartitionName(dir),
488
+ assertThrows(classOf [KafkaException ], () => {
489
+ LocalLog .parseTopicPartitionName(dir)
490
+ ()
491
+ },
489
492
() => " KafkaException should have been thrown for dir: " + dir.getCanonicalPath)
490
493
}
491
494
492
495
@ Test
493
496
def testParseTopicPartitionNameForNull (): Unit = {
494
497
val dir : File = null
495
- assertThrows(classOf [KafkaException ], () => LocalLog .parseTopicPartitionName(dir),
498
+ assertThrows(classOf [KafkaException ], () => {
499
+ LocalLog .parseTopicPartitionName(dir)
500
+ ()
501
+ },
496
502
() => " KafkaException should have been thrown for dir: " + dir)
497
503
}
498
504
@@ -501,11 +507,17 @@ class LocalLogTest {
501
507
val topic = " test_topic"
502
508
val partition = " 1999"
503
509
val dir = new File (logDir, topic + partition)
504
- assertThrows(classOf [KafkaException ], () => LocalLog .parseTopicPartitionName(dir),
510
+ assertThrows(classOf [KafkaException ], () => {
511
+ LocalLog .parseTopicPartitionName(dir)
512
+ ()
513
+ },
505
514
() => " KafkaException should have been thrown for dir: " + dir.getCanonicalPath)
506
515
// also test the "-delete" marker case
507
516
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
+ },
509
521
() => " KafkaException should have been thrown for dir: " + deleteMarkerDir.getCanonicalPath)
510
522
}
511
523
@@ -514,13 +526,19 @@ class LocalLogTest {
514
526
val topic = " "
515
527
val partition = " 1999"
516
528
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
+ },
518
533
() => " KafkaException should have been thrown for dir: " + dir.getCanonicalPath)
519
534
520
535
// also test the "-delete" marker case
521
536
val deleteMarkerDir = new File (logDir, LocalLog .logDeleteDirName(new TopicPartition (topic, partition.toInt)))
522
537
523
- assertThrows(classOf [KafkaException ], () => LocalLog .parseTopicPartitionName(deleteMarkerDir),
538
+ assertThrows(classOf [KafkaException ], () => {
539
+ LocalLog .parseTopicPartitionName(deleteMarkerDir)
540
+ ()
541
+ },
524
542
() => " KafkaException should have been thrown for dir: " + deleteMarkerDir.getCanonicalPath)
525
543
}
526
544
@@ -529,12 +547,18 @@ class LocalLogTest {
529
547
val topic = " test_topic"
530
548
val partition = " "
531
549
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
+ },
533
554
() => " KafkaException should have been thrown for dir: " + dir.getCanonicalPath)
534
555
535
556
// also test the "-delete" marker case
536
557
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
+ },
538
562
() => " KafkaException should have been thrown for dir: " + deleteMarkerDir.getCanonicalPath)
539
563
}
540
564
@@ -543,22 +567,34 @@ class LocalLogTest {
543
567
val topic = " test_topic"
544
568
val partition = " 1999a"
545
569
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
+ },
547
574
() => " KafkaException should have been thrown for dir: " + dir.getCanonicalPath)
548
575
549
576
// also test the "-delete" marker case
550
577
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
+ },
552
582
() => " KafkaException should have been thrown for dir: " + deleteMarkerDir.getCanonicalPath)
553
583
}
554
584
555
585
@ Test
556
586
def testParseTopicPartitionNameForExistingInvalidDir (): Unit = {
557
587
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
+ },
559
592
() => " KafkaException should have been thrown for dir: " + dir1.getCanonicalPath)
560
593
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
+ },
562
598
() => " KafkaException should have been thrown for dir: " + dir2.getCanonicalPath)
563
599
}
564
600
0 commit comments