summaryrefslogtreecommitdiffstats
path: root/feature-state-management/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'feature-state-management/src/main/java')
-rw-r--r--feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/RepositoryAudit.java15
1 files changed, 11 insertions, 4 deletions
diff --git a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/RepositoryAudit.java b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/RepositoryAudit.java
index bf6b2e7b..8f33f929 100644
--- a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/RepositoryAudit.java
+++ b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/RepositoryAudit.java
@@ -522,19 +522,26 @@ public class RepositoryAudit extends DroolsPdpIntegrityMonitor.AuditBase {
private final class RecursivelyDeleteDirectory extends SimpleFileVisitor<Path> {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
- file.toFile().delete();
- return FileVisitResult.CONTINUE;
+ return deletePath("file", file);
}
@Override
public FileVisitResult postVisitDirectory(Path file, IOException ex) throws IOException {
if (ex == null) {
- file.toFile().delete();
- return FileVisitResult.CONTINUE;
+ return deletePath("directory", file);
} else {
throw ex;
}
}
+
+ private FileVisitResult deletePath(String type, Path file) {
+ try {
+ Files.delete(file);
+ } catch (IOException e) {
+ logger.warn("failed to delete {} {}", type, file, e);
+ }
+ return FileVisitResult.CONTINUE;
+ }
}
/* ============================================================ */