FELIX-4165 Check the return value of the file deletion
  and throw IOException if the delete failed

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1513753 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/configadmin/src/main/java/org/apache/felix/cm/file/FilePersistenceManager.java b/configadmin/src/main/java/org/apache/felix/cm/file/FilePersistenceManager.java
index 1a9874c..ddd43c7 100644
--- a/configadmin/src/main/java/org/apache/felix/cm/file/FilePersistenceManager.java
+++ b/configadmin/src/main/java/org/apache/felix/cm/file/FilePersistenceManager.java
@@ -631,7 +631,12 @@
                 // make sure the cfg file does not exists (just for sanity)
                 if ( cfgFile.exists() )
                 {
-                    cfgFile.delete();
+                    // FELIX-4165: detect failure to delete old file
+                    if ( !cfgFile.delete() )
+                    {
+                        throw new IOException( "Cannot remove old file '" + cfgFile + "'; changes in '" + tmpFile
+                            + "' cannot be persisted at this time" );
+                    }
                 }
 
                 // rename the temporary file to the new file