]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-15987 Restart should not fail if temp files can't be deleted
authorDuarte Meneses <duarte.meneses@sonarsource.com>
Wed, 23 Mar 2022 20:07:45 +0000 (15:07 -0500)
committersonartech <sonartech@sonarsource.com>
Mon, 28 Mar 2022 20:02:53 +0000 (20:02 +0000)
server/sonar-main/src/main/java/org/sonar/application/AppFileSystem.java

index bc67eb3289ff3155bd02a79bd8707c8b560f7bf0..e6f547c462a73828f5c95aeff728e4465fd09da4 100644 (file)
@@ -32,12 +32,12 @@ import java.util.EnumSet;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.sonar.application.config.AppSettings;
+import org.sonar.core.util.FileUtils;
 import org.sonar.process.sharedmemoryfile.AllProcessesCommands;
 
 import static java.lang.String.format;
 import static java.nio.file.FileVisitResult.CONTINUE;
 import static org.apache.commons.io.FileUtils.forceMkdir;
-import static org.sonar.process.FileUtils2.deleteDirectory;
 import static org.sonar.process.ProcessProperties.Property.PATH_DATA;
 import static org.sonar.process.ProcessProperties.Property.PATH_LOGS;
 import static org.sonar.process.ProcessProperties.Property.PATH_TEMP;
@@ -111,22 +111,19 @@ public class AppFileSystem implements FileSystem {
     }
 
     @Override
-    public FileVisitResult visitFile(Path filePath, BasicFileAttributes attrs) throws IOException {
-      File file = filePath.toFile();
-      if (file.isDirectory()) {
-        deleteDirectory(file);
-      } else if (filePath.getFileName().equals(SHAREDMEMORY_FILE)) {
+    public FileVisitResult visitFile(Path filePath, BasicFileAttributes attrs) {
+      if (filePath.getFileName().equals(SHAREDMEMORY_FILE)) {
         return CONTINUE;
       } else if (!symLink || !filePath.equals(path)) {
-        Files.delete(filePath);
+        FileUtils.deleteQuietly(filePath);
       }
       return CONTINUE;
     }
 
     @Override
-    public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
+    public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
       if (!dir.equals(path)) {
-        deleteDirectory(dir.toFile());
+        FileUtils.deleteQuietly(dir);
       }
       return CONTINUE;
     }