Use Files.delete() in LocalSnapshotStore 13/82213/2
authorTomas Cere <tomas.cere@pantheon.tech>
Thu, 23 May 2019 08:04:16 +0000 (10:04 +0200)
committerRobert Varga <nite@hq.sk>
Fri, 24 May 2019 06:22:13 +0000 (06:22 +0000)
If delete fails, it needs to be logged so change this up.

Change-Id: If4051cb3e5b83dee51f919fc1713cc17f032597e
Signed-off-by: Tomas Cere <tomas.cere@pantheon.tech>
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/persistence/LocalSnapshotStore.java

index 76babc15db7d831403e985c658e3a3cef46f3e99..62b0cf5bfd061867da72cd4084eb8eec86d72821 100644 (file)
@@ -223,7 +223,13 @@ public class LocalSnapshotStore extends SnapshotStore {
 
         LOG.debug("Deleting files: {}", files);
 
-        files.forEach(File::delete);
+        files.forEach(file -> {
+            try {
+                Files.delete(file.toPath());
+            } catch (IOException | SecurityException e) {
+                LOG.error("Unable to delete snapshot file: {}, persistenceId: {} ", file, persistenceId);
+            }
+        });
         return null;
     }
 
@@ -232,7 +238,13 @@ public class LocalSnapshotStore extends SnapshotStore {
 
         LOG.debug("Deleting files: {}", files);
 
-        files.forEach(File::delete);
+        files.forEach(file -> {
+            try {
+                Files.delete(file.toPath());
+            } catch (IOException | SecurityException e) {
+                LOG.error("Unable to delete snapshot file: {}", file);
+            }
+        });
         return null;
     }