4949
5050import org .apache .commons .io .file .Counters ;
5151import org .apache .commons .io .file .PathUtils ;
52- import org .apache .commons .io .file .StandardDeleteOption ;
5352import org .apache .commons .io .filefilter .DirectoryFileFilter ;
5453import org .apache .commons .io .filefilter .FalseFileFilter ;
5554import org .apache .commons .io .filefilter .FileFilterUtils ;
@@ -331,17 +330,17 @@ public static long checksumCRC32(final File file) throws IOException {
331330 public static void cleanDirectory (final File directory ) throws IOException {
332331 final File [] files = verifiedListFiles (directory );
333332
334- IOException exception = null ;
333+ final List < Exception > causeList = new ArrayList <>() ;
335334 for (final File file : files ) {
336335 try {
337336 forceDelete (file );
338337 } catch (final IOException ioe ) {
339- exception = ioe ;
338+ causeList . add ( ioe ) ;
340339 }
341340 }
342341
343- if (null != exception ) {
344- throw exception ;
342+ if (! causeList . isEmpty () ) {
343+ throw new IOExceptionList ( causeList ) ;
345344 }
346345 }
347346
@@ -356,17 +355,17 @@ public static void cleanDirectory(final File directory) throws IOException {
356355 private static void cleanDirectoryOnExit (final File directory ) throws IOException {
357356 final File [] files = verifiedListFiles (directory );
358357
359- IOException exception = null ;
358+ final List < Exception > causeList = new ArrayList <>() ;
360359 for (final File file : files ) {
361360 try {
362361 forceDeleteOnExit (file );
363362 } catch (final IOException ioe ) {
364- exception = ioe ;
363+ causeList . add ( ioe ) ;
365364 }
366365 }
367366
368- if (null != exception ) {
369- throw exception ;
367+ if (! causeList . isEmpty () ) {
368+ throw new IOExceptionList ( causeList ) ;
370369 }
371370 }
372371
0 commit comments