aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2016-02-11 14:07:01 +0100
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>2016-02-12 13:48:36 +0100
commit8b36b92c75be2da2d16e9d14e3fe2254f6dc4368 (patch)
tree2517bc8b8f7786bcad72cdf3583b143b7d44cad1 /server
parent9af7d4b6c262fe1e0768221f8450dea459fe4986 (diff)
downloadsonarqube-8b36b92c75be2da2d16e9d14e3fe2254f6dc4368.tar.gz
sonarqube-8b36b92c75be2da2d16e9d14e3fe2254f6dc4368.zip
SONAR-7125 use efficient delete dir code in core, batch and server
use Java NIO rather than Common IO FileUtils
Diffstat (limited to 'server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/app/EmbeddedTomcat.java5
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/app/TomcatContexts.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/queue/report/ReportFiles.java6
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/platform/DefaultServerFileSystem.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/platform/RailsAppsDeployer.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/plugins/PluginDownloader.java5
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginJarExploder.java8
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginRepository.java4
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileCopier.java19
9 files changed, 25 insertions, 28 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/app/EmbeddedTomcat.java b/server/sonar-server/src/main/java/org/sonar/server/app/EmbeddedTomcat.java
index 39b5d5c1e0a..432dbae8ff9 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/app/EmbeddedTomcat.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/app/EmbeddedTomcat.java
@@ -24,11 +24,12 @@ import java.io.File;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.core.StandardContext;
import org.apache.catalina.startup.Tomcat;
-import org.apache.commons.io.FileUtils;
import org.sonar.api.utils.log.Loggers;
import org.sonar.process.ProcessProperties;
import org.sonar.process.Props;
+import static org.sonar.core.util.FileUtils.deleteQuietly;
+
class EmbeddedTomcat {
private final Props props;
@@ -97,7 +98,7 @@ class EmbeddedTomcat {
Loggers.get(EmbeddedTomcat.class).error("Fail to stop web server", e);
}
}
- FileUtils.deleteQuietly(tomcatBasedir());
+ deleteQuietly(tomcatBasedir());
}
void awaitTermination() {
diff --git a/server/sonar-server/src/main/java/org/sonar/server/app/TomcatContexts.java b/server/sonar-server/src/main/java/org/sonar/server/app/TomcatContexts.java
index deece74787a..7ed8a009486 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/app/TomcatContexts.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/app/TomcatContexts.java
@@ -136,7 +136,7 @@ public class TomcatContexts {
static class Fs {
void createOrCleanupDir(File dir) throws IOException {
FileUtils.forceMkdir(dir);
- FileUtils.cleanDirectory(dir);
+ org.sonar.core.util.FileUtils.cleanDirectory(dir);
}
}
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/queue/report/ReportFiles.java b/server/sonar-server/src/main/java/org/sonar/server/computation/queue/report/ReportFiles.java
index 255f1d61cbb..1bc74abf973 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/queue/report/ReportFiles.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/queue/report/ReportFiles.java
@@ -49,21 +49,21 @@ public class ReportFiles {
try {
FileUtils.copyInputStreamToFile(reportInput, file);
} catch (Exception e) {
- FileUtils.deleteQuietly(file);
+ org.sonar.core.util.FileUtils.deleteQuietly(file);
IOUtils.closeQuietly(reportInput);
throw new IllegalStateException(format("Fail to copy report to file: %s", file.getAbsolutePath()), e);
}
}
public void deleteIfExists(String taskUuid) {
- FileUtils.deleteQuietly(fileForUuid(taskUuid));
+ org.sonar.core.util.FileUtils.deleteQuietly(fileForUuid(taskUuid));
}
public void deleteAll() {
File dir = reportDir();
if (dir.exists()) {
try {
- FileUtils.cleanDirectory(dir);
+ org.sonar.core.util.FileUtils.cleanDirectory(dir);
} catch (Exception e) {
throw new IllegalStateException(format("Fail to clean directory: %s", dir.getAbsolutePath()), e);
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/DefaultServerFileSystem.java b/server/sonar-server/src/main/java/org/sonar/server/platform/DefaultServerFileSystem.java
index dc41d224733..176f533dbe3 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/platform/DefaultServerFileSystem.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/platform/DefaultServerFileSystem.java
@@ -74,7 +74,7 @@ public class DefaultServerFileSystem implements ServerFileSystem, Startable {
File deprecated = getDeprecatedPluginsDir();
try {
FileUtils.forceMkdir(deprecated);
- FileUtils.cleanDirectory(deprecated);
+ org.sonar.core.util.FileUtils.cleanDirectory(deprecated);
} catch (IOException e) {
throw new IllegalStateException("The following directory can not be created: " + deprecated.getAbsolutePath(), e);
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/RailsAppsDeployer.java b/server/sonar-server/src/main/java/org/sonar/server/platform/RailsAppsDeployer.java
index b4f6391b30f..ee56ab6226d 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/platform/RailsAppsDeployer.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/platform/RailsAppsDeployer.java
@@ -111,7 +111,7 @@ public class RailsAppsDeployer implements Startable {
private void prepareDir(File appsDir) {
if (appsDir.exists() && appsDir.isDirectory()) {
try {
- FileUtils.deleteDirectory(appsDir);
+ org.sonar.core.util.FileUtils.deleteDirectory(appsDir);
} catch (IOException e) {
throw new IllegalStateException("Fail to delete temp directory: " + appsDir, e);
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/plugins/PluginDownloader.java b/server/sonar-server/src/main/java/org/sonar/server/plugins/PluginDownloader.java
index c85905a927f..436e657efa4 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/plugins/PluginDownloader.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/plugins/PluginDownloader.java
@@ -42,14 +42,13 @@ import org.sonar.updatecenter.common.Version;
import static com.google.common.collect.Iterables.transform;
import static com.google.common.collect.Lists.newArrayList;
-import static org.apache.commons.io.FileUtils.cleanDirectory;
import static org.apache.commons.io.FileUtils.copyFile;
import static org.apache.commons.io.FileUtils.copyFileToDirectory;
-import static org.apache.commons.io.FileUtils.deleteQuietly;
import static org.apache.commons.io.FileUtils.forceMkdir;
import static org.apache.commons.io.FileUtils.toFile;
import static org.apache.commons.lang.StringUtils.substringAfterLast;
import static org.sonar.core.platform.PluginInfo.jarToPluginInfo;
+import static org.sonar.core.util.FileUtils.deleteQuietly;
/**
* Downloads plugins from update center. Files are copied in the directory extensions/downloads and then
@@ -95,7 +94,7 @@ public class PluginDownloader implements Startable {
public void cancelDownloads() {
try {
if (downloadDir.exists()) {
- cleanDirectory(downloadDir);
+ org.sonar.core.util.FileUtils.cleanDirectory(downloadDir);
}
} catch (IOException e) {
throw new IllegalStateException("Fail to clean the plugin downloads directory: " + downloadDir, e);
diff --git a/server/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginJarExploder.java b/server/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginJarExploder.java
index e29e063a6aa..db74246c80f 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginJarExploder.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginJarExploder.java
@@ -19,17 +19,15 @@
*/
package org.sonar.server.plugins;
+import java.io.File;
import org.apache.commons.io.FileUtils;
import org.sonar.api.server.ServerSide;
import org.sonar.api.utils.ZipUtils;
import org.sonar.core.platform.ExplodedPlugin;
-import org.sonar.core.platform.PluginJarExploder;
import org.sonar.core.platform.PluginInfo;
+import org.sonar.core.platform.PluginJarExploder;
import org.sonar.server.platform.DefaultServerFileSystem;
-import java.io.File;
-
-import static org.apache.commons.io.FileUtils.cleanDirectory;
import static org.apache.commons.io.FileUtils.forceMkdir;
@ServerSide
@@ -51,7 +49,7 @@ public class ServerPluginJarExploder extends PluginJarExploder {
File toDir = new File(fs.getDeployedPluginsDir(), pluginInfo.getKey());
try {
forceMkdir(toDir);
- cleanDirectory(toDir);
+ org.sonar.core.util.FileUtils.cleanDirectory(toDir);
File jarSource = pluginInfo.getNonNullJarFile();
File jarTarget = new File(toDir, jarSource.getName());
diff --git a/server/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginRepository.java b/server/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginRepository.java
index 90f5d726e92..40bcc6b20dc 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginRepository.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginRepository.java
@@ -53,7 +53,7 @@ import static com.google.common.collect.Iterables.transform;
import static com.google.common.collect.Lists.newArrayList;
import static java.lang.String.format;
import static org.apache.commons.io.FileUtils.copyFile;
-import static org.apache.commons.io.FileUtils.deleteQuietly;
+import static org.sonar.core.util.FileUtils.deleteQuietly;
import static org.apache.commons.io.FileUtils.moveFile;
import static org.apache.commons.io.FileUtils.moveFileToDirectory;
import static org.sonar.core.platform.PluginInfo.jarToPluginInfo;
@@ -159,7 +159,7 @@ public class ServerPluginRepository implements PluginRepository, Startable {
private void registerPluginInfo(PluginInfo info) {
if (blacklistedPluginKeys.contains(info.getKey())) {
LOG.warn("Plugin {} [{}] is blacklisted and is being uninstalled.", info.getName(), info.getKey());
- deleteQuietly(info.getNonNullJarFile());
+ org.sonar.core.util.FileUtils.deleteQuietly(info.getNonNullJarFile());
return;
}
PluginInfo existing = pluginInfosByKeys.put(info.getKey(), info);
diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileCopier.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileCopier.java
index 8844f597751..621717a2d6c 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileCopier.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileCopier.java
@@ -19,15 +19,6 @@
*/
package org.sonar.server.qualityprofile;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang.StringUtils;
-import org.sonar.api.server.ServerSide;
-import org.sonar.api.utils.TempFolder;
-import org.sonar.db.DbSession;
-import org.sonar.db.qualityprofile.QualityProfileDto;
-import org.sonar.db.DbClient;
-
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
@@ -35,6 +26,14 @@ import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.Writer;
import java.nio.charset.StandardCharsets;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.StringUtils;
+import org.sonar.api.server.ServerSide;
+import org.sonar.api.utils.TempFolder;
+import org.sonar.db.DbClient;
+import org.sonar.db.DbSession;
+import org.sonar.db.qualityprofile.QualityProfileDto;
@ServerSide
public class QProfileCopier {
@@ -59,7 +58,7 @@ public class QProfileCopier {
restore(backupFile, QProfileName.createFor(to.getLanguage(), to.getName()));
return to;
} finally {
- FileUtils.deleteQuietly(backupFile);
+ org.sonar.core.util.FileUtils.deleteQuietly(backupFile);
}
}