From 14ecef96e4595f3392bd8355a2013d86a06c9e08 Mon Sep 17 00:00:00 2001 From: Martin Ritchie Date: Fri, 6 Mar 2009 15:46:14 +0000 Subject: 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 --- .../src/main/java/org/apache/qpid/util/FileUtils.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'java/common') 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(); -- cgit v1.2.1