2121import java .io .FileNotFoundException ;
2222import java .io .IOException ;
2323import java .util .ArrayList ;
24+ import java .util .Collections ;
2425import java .util .List ;
2526import java .util .NoSuchElementException ;
2627import java .util .concurrent .ExecutionException ;
2728import java .util .concurrent .ExecutorService ;
2829import java .util .concurrent .Executors ;
2930import java .util .concurrent .Future ;
3031
31- import org .apache .hadoop .test .LambdaTestUtils ;
3232import org .assertj .core .api .Assertions ;
3333import org .junit .Assert ;
3434import org .junit .Test ;
4242import org .apache .hadoop .fs .azurebfs .services .AbfsListStatusRemoteIterator ;
4343import org .apache .hadoop .fs .azurebfs .services .ListingSupport ;
4444import org .apache .hadoop .fs .azurebfs .utils .TracingContext ;
45+ import org .apache .hadoop .test .LambdaTestUtils ;
4546
4647import static org .mockito .ArgumentMatchers .any ;
4748import static org .mockito .ArgumentMatchers .anyBoolean ;
@@ -285,14 +286,16 @@ private void setPageSize(int pageSize) throws IOException {
285286 private List <String > createFilesUnderDirectory (Path rootPath )
286287 throws ExecutionException , InterruptedException , IOException {
287288 final List <Future <Void >> tasks = new ArrayList <>();
288- final List <String > fileNames = new ArrayList <>();
289+ final List <String > fileNames = Collections . synchronizedList ( new ArrayList <>() );
289290 ExecutorService es = Executors .newFixedThreadPool (10 );
290291 try {
291292 for (int i = 0 ; i < ITestAbfsListStatusRemoteIterator .TEST_FILES_NUMBER ; i ++) {
292293 Path filePath = makeQualified (new Path (rootPath , "testListPath" + i ));
293294 tasks .add (es .submit (() -> {
294295 touch (filePath );
295- Assert .assertTrue (fileNames .add (filePath .toString ()));
296+ synchronized (fileNames ) {
297+ Assert .assertTrue (fileNames .add (filePath .toString ()));
298+ }
296299 return null ;
297300 }));
298301 }
@@ -303,7 +306,6 @@ private List<String> createFilesUnderDirectory(Path rootPath)
303306 es .shutdownNow ();
304307 }
305308 LOG .debug (fileNames .toString ());
306- Assertions .assertThat (fileNames ).doesNotContainNull ();
307309 Assertions .assertThat (fileNames )
308310 .describedAs ("File creation incorrect or fileNames not added to list" )
309311 .hasSize (ITestAbfsListStatusRemoteIterator .TEST_FILES_NUMBER );
0 commit comments