diff options
author | Daniel Schwarz <daniel.schwarz@sonarsource.com> | 2017-10-16 16:32:25 +0200 |
---|---|---|
committer | Daniel Schwarz <bartfastiel@users.noreply.github.com> | 2017-10-17 10:01:39 +0200 |
commit | 3e15ddb6e8b8d8195c3d2334bda43a53ffb593a7 (patch) | |
tree | b959ef39fa2955cd388d118f04161f37f613bfc7 /server/sonar-main | |
parent | 908547bead1f995e94c2b219d86e4278915c3081 (diff) | |
download | sonarqube-3e15ddb6e8b8d8195c3d2334bda43a53ffb593a7.tar.gz sonarqube-3e15ddb6e8b8d8195c3d2334bda43a53ffb593a7.zip |
Fix quality flaws
Diffstat (limited to 'server/sonar-main')
-rw-r--r-- | server/sonar-main/src/main/java/org/sonar/application/process/ProcessLauncherImpl.java | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/server/sonar-main/src/main/java/org/sonar/application/process/ProcessLauncherImpl.java b/server/sonar-main/src/main/java/org/sonar/application/process/ProcessLauncherImpl.java index 3da6b18a0b7..181109a50c9 100644 --- a/server/sonar-main/src/main/java/org/sonar/application/process/ProcessLauncherImpl.java +++ b/server/sonar-main/src/main/java/org/sonar/application/process/ProcessLauncherImpl.java @@ -42,6 +42,7 @@ import org.sonar.process.sharedmemoryfile.AllProcessesCommands; import org.sonar.process.sharedmemoryfile.ProcessCommands; import static java.lang.String.format; +import static java.util.Objects.requireNonNull; 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; @@ -142,7 +143,7 @@ public class ProcessLauncherImpl implements ProcessLauncher { } } - private Process launchJava(JavaCommand javaCommand) { + private <T extends JvmOptions> Process launchJava(JavaCommand<T> javaCommand) { ProcessId processId = javaCommand.getProcessId(); try { ProcessBuilder processBuilder = create(javaCommand); @@ -164,7 +165,9 @@ public class ProcessLauncherImpl implements ProcessLauncher { private ProcessBuilder create(EsScriptCommand esScriptCommand) { List<String> commands = new ArrayList<>(); - commands.add(esScriptCommand.getEsInstallation().getExecutable().getAbsolutePath()); + EsInstallation esInstallation = esScriptCommand.getEsInstallation(); + requireNonNull(esInstallation, () -> "No Elasticsearch installation configuration is available for the command of type " + esScriptCommand.getClass()); + commands.add(esInstallation.getExecutable().getAbsolutePath()); commands.addAll(esScriptCommand.getOptions()); return create(esScriptCommand, commands); @@ -205,7 +208,7 @@ public class ProcessLauncherImpl implements ProcessLauncher { return new File(new File(System.getProperty("java.home")), "bin" + separator + "java").getAbsolutePath(); } - private static List<String> buildClasspath(JavaCommand javaCommand) { + private static <T extends JvmOptions> List<String> buildClasspath(JavaCommand<T> javaCommand) { String pathSeparator = System.getProperty("path.separator"); return Arrays.asList("-cp", String.join(pathSeparator, javaCommand.getClasspath())); } |