You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2016/07/28 19:30:56 UTC

[3/4] activemq-artemis git commit: Avoid NPE if deleteDirectory fails to list files to clean up

Avoid NPE if deleteDirectory fails to list files to clean up


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/f981dbd7
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/f981dbd7
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/f981dbd7

Branch: refs/heads/master
Commit: f981dbd7cfd61d5de3c682001a13179e560c54b4
Parents: 7a5d143
Author: Ville Skytt� <vi...@iki.fi>
Authored: Thu Jul 28 20:02:04 2016 +0300
Committer: Clebert Suconic <cl...@apache.org>
Committed: Thu Jul 28 15:25:45 2016 -0400

----------------------------------------------------------------------
 .../org/apache/activemq/artemis/utils/FileUtil.java    | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/f981dbd7/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/FileUtil.java
----------------------------------------------------------------------
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/FileUtil.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/FileUtil.java
index a6bf055..76b6db4 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/FileUtil.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/FileUtil.java
@@ -63,10 +63,15 @@ public class FileUtil {
             attempts++;
          }
 
-         for (String file : files) {
-            File f = new File(directory, file);
-            if (!deleteDirectory(f)) {
-               logger.warn("Failed to clean up file: " + f.getAbsolutePath());
+         if (files == null) {
+            logger.warn("Could not list files to clean up in: " + directory.getAbsolutePath());
+         }
+         else {
+            for (String file : files) {
+               File f = new File(directory, file);
+               if (!deleteDirectory(f)) {
+                  logger.warn("Failed to clean up file: " + f.getAbsolutePath());
+               }
             }
          }
       }