From: simonbrandhof Date: Thu, 16 Dec 2010 14:23:21 +0000 (+0000) Subject: SONAR-1948 Temporary folder is not deleted after installation of plugins X-Git-Tag: 2.6~289 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=754e9f69fde222558a49176759c5adb8f1d4135d;p=sonarqube.git SONAR-1948 Temporary folder is not deleted after installation of plugins --- diff --git a/sonar-server/src/main/java/org/sonar/server/plugins/PluginDeployer.java b/sonar-server/src/main/java/org/sonar/server/plugins/PluginDeployer.java index b78b00cdea2..6da8ea3fd49 100644 --- a/sonar-server/src/main/java/org/sonar/server/plugins/PluginDeployer.java +++ b/sonar-server/src/main/java/org/sonar/server/plugins/PluginDeployer.java @@ -19,6 +19,8 @@ */ package org.sonar.server.plugins; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; import org.apache.commons.io.FileUtils; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; @@ -36,9 +38,6 @@ import org.sonar.server.platform.DefaultServerFileSystem; import org.sonar.server.platform.ServerStartException; import org.sonar.updatecenter.common.PluginKeyUtils; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; - import java.io.File; import java.io.IOException; import java.net.URL; @@ -105,7 +104,7 @@ public final class PluginDeployer implements ServerComponent { public List getUninstalls() { List names = Lists.newArrayList(); if (fileSystem.getRemovedPluginsDir().exists()) { - List files = (List) FileUtils.listFiles(fileSystem.getRemovedPluginsDir(), new String[] { "jar" }, false); + List files = (List) FileUtils.listFiles(fileSystem.getRemovedPluginsDir(), new String[]{"jar"}, false); for (File file : files) { names.add(file.getName()); } @@ -115,7 +114,7 @@ public final class PluginDeployer implements ServerComponent { public void cancelUninstalls() { if (fileSystem.getRemovedPluginsDir().exists()) { - List files = (List) FileUtils.listFiles(fileSystem.getRemovedPluginsDir(), new String[] { "jar" }, false); + List files = (List) FileUtils.listFiles(fileSystem.getRemovedPluginsDir(), new String[]{"jar"}, false); for (File file : files) { try { FileUtils.moveFileToDirectory(file, fileSystem.getUserPluginsDir(), false); @@ -199,6 +198,7 @@ public final class PluginDeployer implements ServerComponent { FileUtils.copyFile(file, target); plugin.addDeployedFile(target); } + FileUtils.deleteQuietly(tempDir); } classloaders.create(plugin); @@ -221,7 +221,7 @@ public final class PluginDeployer implements ServerComponent { private void moveAndLoadDownloadedPlugins() throws IOException { if (fileSystem.getDownloadedPluginsDir().exists()) { - Collection jars = FileUtils.listFiles(fileSystem.getDownloadedPluginsDir(), new String[] { "jar" }, false); + Collection jars = FileUtils.listFiles(fileSystem.getDownloadedPluginsDir(), new String[]{"jar"}, false); for (File jar : jars) { File movedJar = moveDownloadedFile(jar); if (movedJar != null) { @@ -284,7 +284,7 @@ public final class PluginDeployer implements ServerComponent { String mainClass = plugin.getMainClass(); try { - URLClassLoader pluginClassLoader = URLClassLoader.newInstance(new URL[] { tempFile.toURI().toURL() }, getClass().getClassLoader()); + URLClassLoader pluginClassLoader = URLClassLoader.newInstance(new URL[]{tempFile.toURI().toURL()}, getClass().getClassLoader()); Plugin pluginInstance = (Plugin) pluginClassLoader.loadClass(mainClass).newInstance(); plugin.setKey(PluginKeyUtils.sanitize(pluginInstance.getKey())); plugin.setDescription(pluginInstance.getDescription());