2323import java .io .OutputStream ;
2424import java .util .ArrayList ;
2525import java .util .Collection ;
26+ import java .util .Collections ;
2627import java .util .Iterator ;
2728import java .util .List ;
28- import java .util .concurrent .CopyOnWriteArrayList ;
2929import java .util .concurrent .CountDownLatch ;
3030import java .util .concurrent .ExecutorService ;
3131import java .util .concurrent .Executors ;
@@ -227,8 +227,7 @@ void loadINodeDirectorySectionInParallel(ExecutorService service,
227227 LOG .info ("Loading the INodeDirectory section in parallel with {} sub-" +
228228 "sections" , sections .size ());
229229 CountDownLatch latch = new CountDownLatch (sections .size ());
230- final CopyOnWriteArrayList <IOException > exceptions =
231- new CopyOnWriteArrayList <>();
230+ final List <IOException > exceptions = Collections .synchronizedList (new ArrayList <>());
232231 for (FileSummary .Section s : sections ) {
233232 service .submit (() -> {
234233 InputStream ins = null ;
@@ -237,8 +236,7 @@ void loadINodeDirectorySectionInParallel(ExecutorService service,
237236 compressionCodec );
238237 loadINodeDirectorySection (ins );
239238 } catch (Exception e ) {
240- LOG .error ("An exception occurred loading INodeDirectories in " +
241- "parallel" , e );
239+ LOG .error ("An exception occurred loading INodeDirectories in parallel" , e );
242240 exceptions .add (new IOException (e ));
243241 } finally {
244242 latch .countDown ();
@@ -424,8 +422,7 @@ void loadINodeSectionInParallel(ExecutorService service,
424422 long expectedInodes = 0 ;
425423 CountDownLatch latch = new CountDownLatch (sections .size ());
426424 AtomicInteger totalLoaded = new AtomicInteger (0 );
427- final CopyOnWriteArrayList <IOException > exceptions =
428- new CopyOnWriteArrayList <>();
425+ final List <IOException > exceptions = Collections .synchronizedList (new ArrayList <>());
429426
430427 for (int i =0 ; i < sections .size (); i ++) {
431428 FileSummary .Section s = sections .get (i );
0 commit comments