activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [3/4] activemq-artemis git commit: Avoid NPE if deleteDirectory fails to list files to clean up
Date Thu, 28 Jul 2016 19:30:56 GMT
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ä <ville.skytta@iki.fi>
Authored: Thu Jul 28 20:02:04 2016 +0300
Committer: Clebert Suconic <clebertsuconic@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());
+               }
             }
          }
       }


Mime
View raw message