diff options
author | Pierre Guillot <50145663+pierre-guillot-sonarsource@users.noreply.github.com> | 2020-08-11 16:49:42 +0200 |
---|---|---|
committer | Malena Ebert <malena.ebert@sonarsource.com> | 2020-08-28 11:43:56 +0200 |
commit | ed1a72601c559e86ccd96004c99157421b6bcb20 (patch) | |
tree | 2b39782d8e8d0e7f3d538000e5147bc644688471 | |
parent | 7721c3eeab3202e91fb9c87dfaec4ba3a7b4d0df (diff) | |
download | sonarqube-ed1a72601c559e86ccd96004c99157421b6bcb20.tar.gz sonarqube-ed1a72601c559e86ccd96004c99157421b6bcb20.zip |
use try-with-ressource to write log4j ES properties
-rw-r--r-- | server/sonar-main/src/main/java/org/sonar/application/ProcessLauncherImpl.java | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/server/sonar-main/src/main/java/org/sonar/application/ProcessLauncherImpl.java b/server/sonar-main/src/main/java/org/sonar/application/ProcessLauncherImpl.java index 674dbdcb16c..e0c4aab97f2 100644 --- a/server/sonar-main/src/main/java/org/sonar/application/ProcessLauncherImpl.java +++ b/server/sonar-main/src/main/java/org/sonar/application/ProcessLauncherImpl.java @@ -50,10 +50,10 @@ import static com.google.common.base.Preconditions.checkArgument; import static java.lang.String.format; import static java.util.Collections.singleton; import static java.util.Objects.requireNonNull; +import static org.sonar.process.ProcessEntryPoint.PROPERTY_GRACEFUL_STOP_TIMEOUT_MS; import static org.sonar.process.ProcessEntryPoint.PROPERTY_PROCESS_INDEX; import static org.sonar.process.ProcessEntryPoint.PROPERTY_PROCESS_KEY; import static org.sonar.process.ProcessEntryPoint.PROPERTY_SHARED_PATH; -import static org.sonar.process.ProcessEntryPoint.PROPERTY_GRACEFUL_STOP_TIMEOUT_MS; public class ProcessLauncherImpl implements ProcessLauncher { private static final Logger LOG = LoggerFactory.getLogger(ProcessLauncherImpl.class); @@ -148,10 +148,10 @@ public class ProcessLauncherImpl implements ProcessLauncher { throw new IllegalStateException(error); } - try { - esInstallation.getEsYmlSettings().writeToYmlSettingsFile(esInstallation.getElasticsearchYml()); - esInstallation.getEsJvmOptions().writeToJvmOptionFile(esInstallation.getJvmOptions()); - esInstallation.getLog4j2Properties().store(new FileOutputStream(esInstallation.getLog4j2PropertiesLocation()), "log4j2 properties file for ES bundled in SonarQube"); + esInstallation.getEsYmlSettings().writeToYmlSettingsFile(esInstallation.getElasticsearchYml()); + esInstallation.getEsJvmOptions().writeToJvmOptionFile(esInstallation.getJvmOptions()); + try (FileOutputStream fileOutputStream = new FileOutputStream(esInstallation.getLog4j2PropertiesLocation())) { + esInstallation.getLog4j2Properties().store(fileOutputStream, "log4j2 properties file for ES bundled in SonarQube"); } catch (IOException e) { throw new IllegalStateException("Failed to write ES configuration files", e); } |