Author: ritchiem
Date: Mon Mar 9 16:00:18 2009
New Revision: 751720
URL: http://svn.apache.org/viewvc?rev=751720&view=rev
Log:
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.
Modified:
qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/util/FileUtils.java
qpid/trunk/qpid/java/common/src/test/java/org/apache/qpid/util/FileUtilsTest.java
Modified:
qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/util/FileUtils.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/util/FileUtils.java?rev=751720&r1=751719&r2=751720&view=diff
==============================================================================
---
qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/util/FileUtils.java
(original)
+++
qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/util/FileUtils.java
Mon Mar 9 16:00:18 2009
@@ -246,12 +246,6 @@
{
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 @@
return false;
}
- return success && file.delete();
+ return file.delete();
}
Modified:
qpid/trunk/qpid/java/common/src/test/java/org/apache/qpid/util/FileUtilsTest.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/common/src/test/java/org/apache/qpid/util/FileUtilsTest.java?rev=751720&r1=751719&r2=751720&view=diff
==============================================================================
---
qpid/trunk/qpid/java/common/src/test/java/org/apache/qpid/util/FileUtilsTest.java
(original)
+++
qpid/trunk/qpid/java/common/src/test/java/org/apache/qpid/util/FileUtilsTest.java
Mon Mar 9 16:00:18 2009
@@ -287,9 +287,23 @@
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
*
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:[email protected]