Skip to content

Commit 7ec3387

Browse files
author
Gary Gregory
committed
Reuse IOExceptionList and fix checkstyle unused imports.
1 parent 69dc2f2 commit 7ec3387

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

src/main/java/org/apache/commons/io/FileUtils.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949

5050
import org.apache.commons.io.file.Counters;
5151
import org.apache.commons.io.file.PathUtils;
52-
import org.apache.commons.io.file.StandardDeleteOption;
5352
import org.apache.commons.io.filefilter.DirectoryFileFilter;
5453
import org.apache.commons.io.filefilter.FalseFileFilter;
5554
import 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

Comments
 (0)