@@ -155,6 +155,7 @@ public void testEmptyLog() throws IOException {
155155 assertEquals (0 , writer .getCurrentSize (), "Just created this log, size should be 0" );
156156 assertTrue (writer .getLogFile ().getFileName ().startsWith ("." ), "Check all log files should start with a ." );
157157 assertEquals (1 , writer .getLogFile ().getLogVersion (), "Version should be 1 for new log created" );
158+ writer .close ();
158159 }
159160
160161 @ ParameterizedTest
@@ -698,7 +699,7 @@ public void testBasicAppendAndScanMultipleFiles(ExternalSpillableMap.DiskMapType
698699
699700 assertEquals (scannedRecords .size (), allRecords .stream ().mapToLong (Collection ::size ).sum (),
700701 "Scanner records count should be the same as appended records" );
701-
702+ scanner . close ();
702703 }
703704
704705 @ Test
@@ -933,6 +934,7 @@ public void testAvroLogRecordReaderBasic(ExternalSpillableMap.DiskMapType diskMa
933934 copyOfRecords1 .stream ().map (s -> ((GenericRecord ) s ).get (HoodieRecord .RECORD_KEY_METADATA_FIELD ).toString ())
934935 .collect (Collectors .toSet ());
935936 assertEquals (originalKeys , readKeys , "CompositeAvroLogReader should return 200 records from 2 versions" );
937+ scanner .close ();
936938 }
937939
938940 @ ParameterizedTest
@@ -1017,6 +1019,7 @@ public void testAvroLogRecordReaderWithRollbackTombstone(ExternalSpillableMap.Di
10171019 copyOfRecords1 .stream ().map (s -> ((GenericRecord ) s ).get (HoodieRecord .RECORD_KEY_METADATA_FIELD ).toString ())
10181020 .collect (Collectors .toSet ());
10191021 assertEquals (originalKeys , readKeys , "CompositeAvroLogReader should return 200 records from 2 versions" );
1022+ scanner .close ();
10201023 }
10211024
10221025 @ ParameterizedTest
@@ -1106,6 +1109,7 @@ public void testAvroLogRecordReaderWithFailedPartialBlock(ExternalSpillableMap.D
11061109 copyOfRecords1 .stream ().map (s -> ((GenericRecord ) s ).get (HoodieRecord .RECORD_KEY_METADATA_FIELD ).toString ())
11071110 .collect (Collectors .toSet ());
11081111 assertEquals (originalKeys , readKeys , "CompositeAvroLogReader should return 200 records from 2 versions" );
1112+ scanner .close ();
11091113 }
11101114
11111115 @ ParameterizedTest
@@ -1243,6 +1247,8 @@ public void testAvroLogRecordReaderWithDeleteAndRollback(ExternalSpillableMap.Di
12431247 Collections .sort (firstBlockRecords );
12441248 Collections .sort (readKeys );
12451249 assertEquals (firstBlockRecords , readKeys , "CompositeAvroLogReader should return 150 records from 2 versions" );
1250+ writer .close ();
1251+ scanner .close ();
12461252 }
12471253
12481254 @ ParameterizedTest
@@ -1360,6 +1366,8 @@ public void testAvroLogRecordReaderWithDisorderDelete(ExternalSpillableMap.DiskM
13601366 Collections .sort (originalKeys );
13611367 Collections .sort (readKeys );
13621368 assertEquals (originalKeys , readKeys , "HoodieMergedLogRecordScanner should return 180 records from 4 versions" );
1369+ writer .close ();
1370+ scanner .close ();
13631371 }
13641372
13651373 @ ParameterizedTest
@@ -1447,6 +1455,8 @@ public void testAvroLogRecordReaderWithFailedRollbacks(ExternalSpillableMap.Disk
14471455 scanner .forEach (s -> readKeys .add (s .getKey ().getRecordKey ()));
14481456 assertEquals (0 , readKeys .size (), "Stream collect should return all 0 records" );
14491457 FileCreateUtils .deleteDeltaCommit (basePath , "100" , fs );
1458+ writer .close ();
1459+ scanner .close ();
14501460 }
14511461
14521462 @ ParameterizedTest
@@ -1513,6 +1523,8 @@ public void testAvroLogRecordReaderWithInsertDeleteAndRollback(ExternalSpillable
15131523 .build ();
15141524 assertEquals (0 , scanner .getTotalLogRecords (), "We would read 0 records" );
15151525 FileCreateUtils .deleteDeltaCommit (basePath , "100" , fs );
1526+ writer .close ();
1527+ scanner .close ();
15161528 }
15171529
15181530 @ ParameterizedTest
@@ -1568,6 +1580,8 @@ public void testAvroLogRecordReaderWithInvalidRollback(ExternalSpillableMap.Disk
15681580 final List <String > readKeys = new ArrayList <>(100 );
15691581 scanner .forEach (s -> readKeys .add (s .getKey ().getRecordKey ()));
15701582 assertEquals (100 , readKeys .size (), "Stream collect should return all 150 records" );
1583+ writer .close ();
1584+ scanner .close ();
15711585 }
15721586
15731587 @ ParameterizedTest
@@ -1637,6 +1651,8 @@ public void testAvroLogRecordReaderWithInsertsDeleteAndRollback(ExternalSpillabl
16371651 .withUseScanV2 (useScanv2 )
16381652 .build ();
16391653 assertEquals (0 , scanner .getTotalLogRecords (), "We would read 0 records" );
1654+ writer .close ();
1655+ scanner .close ();
16401656 }
16411657
16421658 @ ParameterizedTest
@@ -1746,6 +1762,7 @@ public void testAvroLogRecordReaderWithMixedInsertsCorruptsAndRollback(ExternalS
17461762 .build ();
17471763 assertEquals (0 , scanner .getTotalLogRecords (), "We would read 0 records" );
17481764 FileCreateUtils .deleteDeltaCommit (basePath , "100" , fs );
1765+ scanner .close ();
17491766 }
17501767
17511768 @ ParameterizedTest
@@ -1936,6 +1953,7 @@ public void testAvroLogRecordReaderWithMixedInsertsCorruptsRollbackAndMergedLogB
19361953 assertEquals (expectedBlockInstants , validBlockInstants );
19371954 Collections .sort (readKeys );
19381955 assertEquals (expectedRecords , readKeys , "Record keys read should be exactly same." );
1956+ scanner .close ();
19391957 }
19401958
19411959 /*
@@ -2013,7 +2031,7 @@ private void testAvroLogRecordReaderMergingMultipleLogFiles(int numRecordsInLog1
20132031
20142032 assertEquals (Math .max (numRecordsInLog1 , numRecordsInLog2 ), scanner .getNumMergedRecordsInLog (),
20152033 "We would read 100 records" );
2016-
2034+ scanner . close ();
20172035 } catch (Exception e ) {
20182036 e .printStackTrace ();
20192037 }
0 commit comments