summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/common/src/main/java/org/apache/qpid/util/FileUtils.java8
-rw-r--r--java/common/src/test/java/org/apache/qpid/util/FileUtilsTest.java16
2 files changed, 16 insertions, 8 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 029e298c32..e4bfb9c664 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,12 +246,6 @@ 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 || !file.exists())
- {
- return true;
- }
-
if (file.isDirectory())
{
if (recursive)
@@ -267,7 +261,7 @@ public class FileUtils
return false;
}
- return success && file.delete();
+ return file.delete();
}
diff --git a/java/common/src/test/java/org/apache/qpid/util/FileUtilsTest.java b/java/common/src/test/java/org/apache/qpid/util/FileUtilsTest.java
index 76d39200c1..94e7e20a86 100644
--- a/java/common/src/test/java/org/apache/qpid/util/FileUtilsTest.java
+++ b/java/common/src/test/java/org/apache/qpid/util/FileUtilsTest.java
@@ -287,9 +287,23 @@ public class FileUtilsTest extends TestCase
assertTrue("File exists", !test.exists());
assertFalse("File is a directory", test.isDirectory());
- assertTrue("Unable to delete",FileUtils.delete(test,true));
+ assertTrue("Delete Succeeded ", !FileUtils.delete(test, true));
}
+ public void testDeleteNull()
+ {
+ try
+ {
+ FileUtils.delete(null, true);
+ fail("Delete with null value should throw NPE.");
+ }
+ catch (NullPointerException npe)
+ {
+ // expected path
+ }
+ }
+
+
/**
* Given two lists of File arrays ensure they are the same length and all entries in Before are in After
*