Use Files.delete() in LocalSnapshotStore 28/82228/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 08:53:41 +0000 (08:53 +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>
(cherry picked from commit d8ef44c67accea4006489e4cbb6c8f0d4d428b6a)

opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/persistence/LocalSnapshotStore.java

index e1589ffb899a955be8fdcf26fa70565b249a8ab8..893e4e2c39fbcfaef09d913f6b01a5815e0b4590 100644 (file)
@@ -219,7 +219,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;
     }
 
@@ -228,7 +234,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;
     }