summaryrefslogtreecommitdiff
path: root/java/common
diff options
context:
space:
mode:
authorMartin Ritchie <ritchiem@apache.org>2009-03-06 15:46:14 +0000
committerMartin Ritchie <ritchiem@apache.org>2009-03-06 15:46:14 +0000
commit14ecef96e4595f3392bd8355a2013d86a06c9e08 (patch)
treebca53cae3464771ecd9623a1c14803551a58d78f /java/common
parent46f31b3247d507122eed102bfcc395c18fd0bfa8 (diff)
downloadqpid-python-14ecef96e4595f3392bd8355a2013d86a06c9e08.tar.gz
FileUtils : Was not correctly handling the case where a File object became null, it would previously have thrown a NPE which was erroneously caught this and declared the delete to have failed. If there is nothing to delete (signified by the Null File object) then the delete should pass.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@750946 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/common')
-rw-r--r--java/common/src/main/java/org/apache/qpid/util/FileUtils.java15
1 files changed, 8 insertions, 7 deletions
diff --git a/java/common/src/main/java/org/apache/qpid/util/FileUtils.java b/java/common/src/main/java/org/apache/qpid/util/FileUtils.java
index 3d43b9d511..585657c8bb 100644
--- a/java/common/src/main/java/org/apache/qpid/util/FileUtils.java
+++ b/java/common/src/main/java/org/apache/qpid/util/FileUtils.java
@@ -246,18 +246,19 @@ public class FileUtils
{
boolean success = true;
+ // If we have nothing to delete then it must be ok to say it was deleted.
+ if (file == null)
+ {
+ return true;
+ }
+
if (file.isDirectory())
{
if (recursive)
{
- try{
- for (File subFile : file.listFiles())
- {
- success = delete(subFile, true) & success ;
- }
- }catch (NullPointerException npe)
+ for (File subFile : file.listFiles())
{
- success = false;
+ success = delete(subFile, true) & success ;
}
return success && file.delete();