From 69dd5dc2ea6b2bd03af6c5365ef5cdcbbf34d777 Mon Sep 17 00:00:00 2001 From: Jacek Date: Thu, 28 Apr 2022 11:40:10 +0200 Subject: [PATCH] Delete files if exist in ScoreMatrixDumperImplTest --- .../filemove/ScoreMatrixDumperImplTest.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/filemove/ScoreMatrixDumperImplTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/filemove/ScoreMatrixDumperImplTest.java index cc3da964b27..5c9e2d851bb 100644 --- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/filemove/ScoreMatrixDumperImplTest.java +++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/filemove/ScoreMatrixDumperImplTest.java @@ -66,15 +66,13 @@ public class ScoreMatrixDumperImplTest { @After public void cleanUp() { try { - FileUtils.listFiles(tempDir.toFile(), new AbstractFileFilter() { - @Override - public boolean accept(File file) { - if (file.getName().contains("score-matrix-")) { - file.delete(); - } - return false; + Files.list(tempDir.toAbsolutePath()).filter(p -> p.getFileName().toString().contains("score-matrix-")).forEach((p) -> { + try { + Files.deleteIfExists(p); + } catch (Exception e) { + System.out.println("Could not delete file. Details: " + e.getMessage()); } - }, null); + }); } catch (Exception e) { System.out.println("Cleaning up temp directory failed. Details: " + e.getMessage()); } -- 2.39.5