From d8ef44c67accea4006489e4cbb6c8f0d4d428b6a Mon Sep 17 00:00:00 2001 From: Tomas Cere Date: Thu, 23 May 2019 10:04:16 +0200 Subject: [PATCH] Use Files.delete() in LocalSnapshotStore If delete fails, it needs to be logged so change this up. Change-Id: If4051cb3e5b83dee51f919fc1713cc17f032597e Signed-off-by: Tomas Cere --- .../cluster/persistence/LocalSnapshotStore.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/persistence/LocalSnapshotStore.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/persistence/LocalSnapshotStore.java index 76babc15db..62b0cf5bfd 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/persistence/LocalSnapshotStore.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/persistence/LocalSnapshotStore.java @@ -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; } -- 2.36.6