garydgregory commented on a change in pull request #294:
URL: https://github.com/apache/commons-io/pull/294#discussion_r740267789



##########
File path: src/main/java/org/apache/commons/io/FileUtils.java
##########
@@ -340,19 +340,26 @@ public static long checksumCRC32(final File file) throws 
IOException {
      * @see #forceDelete(File)
      */
     public static void cleanDirectory(final File directory) throws IOException 
{
-        final File[] files = listFiles(directory, null);
-
-        final List<Exception> causeList = new ArrayList<>();
-        for (final File file : files) {
-            try {
-                forceDelete(file);
-            } catch (final IOException ioe) {
-                causeList.add(ioe);
-            }
+        if (directory == null) {
+            return;
         }
-
-        if (!causeList.isEmpty()) {
-            throw new IOExceptionList(directory.toString(), causeList);
+        if (directory.exists()) {
+            if (directory.isDirectory()) {
+                if (Objects.requireNonNull(directory.listFiles(), "File is not 
directory").length != 0) {
+                    
Arrays.stream(Objects.requireNonNull(directory.listFiles(), "File is not 
directory")).forEach(file -> {
+                        try {
+                            if (file.isDirectory() && 
Objects.requireNonNull(file.listFiles()).length != 0) {
+                                cleanDirectory(file);
+                            }
+                            Files.delete(directory.toPath());
+                        } catch (IOException e) {
+                            e.printStackTrace();

Review comment:
       Never output to the console.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to