diff options
author | Jim Hahn <jrh3@att.com> | 2020-04-08 10:46:40 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2020-04-08 10:58:48 -0400 |
commit | 18c81f810f26f57196c0a2ebcbd911a2f822c1db (patch) | |
tree | ff571bcce6c69affd9acaefe5f92e496ee57a34f /feature-state-management | |
parent | 277036656448dbfd2cfe310e43d0a0b713504aea (diff) |
Address more sonar issues in drools-pdp
Addressed the following sonar issues:
- use of "synchronized"
- use Files.delete() instead of File.delete()
Issue-ID: POLICY-2305
Change-Id: Id55628fe12d9d764616e57321382a70cb5704ba1
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'feature-state-management')
-rw-r--r-- | feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/RepositoryAudit.java | 15 |
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; + } } /* ============================================================ */ |