]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4898 remove props temporary file as soon as possible
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 4 Aug 2014 17:08:42 +0000 (19:08 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 4 Aug 2014 17:22:33 +0000 (19:22 +0200)
server/sonar-process/src/main/java/org/sonar/process/ConfigurationUtils.java
server/sonar-process/src/main/java/org/sonar/process/ProcessWrapper.java

index 5430aa261735d910c4580ef607a4b32458ef3c6a..9d2cfd3fa7419c908032bc6e09fd0ac317c5aaca 100644 (file)
@@ -19,6 +19,7 @@
  */
 package org.sonar.process;
 
+import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang.text.StrSubstitutor;
 
@@ -67,6 +68,7 @@ public final class ConfigurationUtils {
       throw new IllegalStateException("Could not read properties from file '" + args[0] + "'", e);
     } finally {
       IOUtils.closeQuietly(reader);
+      FileUtils.deleteQuietly(propertyFile);
     }
     return new Props(properties);
   }
index aabb6a8cc668ead65400b9147fd347accb2289d1..6eba8b801c3a5fc1e6838c9ad04d6cfa03cd4335 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.process;
 
-import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
@@ -77,7 +76,6 @@ public class ProcessWrapper extends Thread implements Terminable {
   private final Map<String, String> envProperties = new HashMap<String, String>();
   private final Properties properties = new Properties();
   private File workDir;
-  private File propertiesFile;
   private Process process;
   private StreamGobbler errorGobbler;
   private StreamGobbler outputGobbler;
@@ -180,7 +178,6 @@ public class ProcessWrapper extends Thread implements Terminable {
       waitUntilFinish(outputGobbler);
       waitUntilFinish(errorGobbler);
       ProcessUtils.closeStreams(process);
-      FileUtils.deleteQuietly(propertiesFile);
     }
   }
 
@@ -225,6 +222,7 @@ public class ProcessWrapper extends Thread implements Terminable {
   }
 
   private File buildPropertiesFile() {
+    File propertiesFile = null;
     try {
       propertiesFile = File.createTempFile("sq-conf", "properties");
       Properties props = new Properties();