From: Jacek Date: Thu, 28 Apr 2022 09:40:10 +0000 (+0200) Subject: Delete files if exist in ScoreMatrixDumperImplTest X-Git-Tag: 9.5.0.56709~202 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=69dd5dc2ea6b2bd03af6c5365ef5cdcbbf34d777;p=sonarqube.git Delete files if exist in ScoreMatrixDumperImplTest --- 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()); }