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 76babc1..62b0cf5 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;
     }
 

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.