summaryrefslogtreecommitdiff
path: root/java/common
diff options
context:
space:
mode:
authorMartin Ritchie <ritchiem@apache.org>2009-03-09 16:00:18 +0000
committerMartin Ritchie <ritchiem@apache.org>2009-03-09 16:00:18 +0000
commit63c96bcd1d6be31678b9fb8a0caeb5dc5268a2a3 (patch)
tree5ee476692342b8861ca870dcfac21c3c1f361683 /java/common
parent1214783620f81f2b0b1e69c4c4df874d58cdf85b (diff)
downloadqpid-python-63c96bcd1d6be31678b9fb8a0caeb5dc5268a2a3.tar.gz
Removed false positive return from FU.delete(). Delete mirrors functionality provided by java.io. Attempting to delete an non-existent file returns false. The caller must handle this correctly. If client provides a null value then the call will throw a NPE which is a valid java response.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@751720 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/common')
-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
*