]> source.dussan.org Git - sonarqube.git/commitdiff
Delete files if exist in ScoreMatrixDumperImplTest
authorJacek <jacek.poreda@sonarsource.com>
Thu, 28 Apr 2022 09:40:10 +0000 (11:40 +0200)
committersonartech <sonartech@sonarsource.com>
Thu, 28 Apr 2022 20:02:52 +0000 (20:02 +0000)
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/filemove/ScoreMatrixDumperImplTest.java

index cc3da964b2739dd831eb34d24846f9900804f3b3..5c9e2d851bbc0ee57b2f12fbced4ff6ed007f12c 100644 (file)
@@ -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());
     }