aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-process-monitor/src
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-process-monitor/src')
-rw-r--r--server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/JavaCommand.java10
-rw-r--r--server/sonar-process-monitor/src/test/java/org/sonar/process/monitor/JavaCommandTest.java7
2 files changed, 14 insertions, 3 deletions
diff --git a/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/JavaCommand.java b/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/JavaCommand.java
index 7750b6deb35..76abf52deba 100644
--- a/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/JavaCommand.java
+++ b/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/JavaCommand.java
@@ -19,6 +19,8 @@
*/
package org.sonar.process.monitor;
+import org.apache.commons.lang.StringUtils;
+
import javax.annotation.Nullable;
import java.io.File;
@@ -84,12 +86,16 @@ public class JavaCommand {
}
public JavaCommand addJavaOption(String s) {
- javaOptions.add(s);
+ if (StringUtils.isNotBlank(s)) {
+ javaOptions.add(s);
+ }
return this;
}
public JavaCommand addJavaOptions(String s) {
- Collections.addAll(javaOptions, s.split(" "));
+ for (String opt : s.split(" ")) {
+ addJavaOption(opt);
+ }
return this;
}
diff --git a/server/sonar-process-monitor/src/test/java/org/sonar/process/monitor/JavaCommandTest.java b/server/sonar-process-monitor/src/test/java/org/sonar/process/monitor/JavaCommandTest.java
index fbfbad11b54..689f061ff06 100644
--- a/server/sonar-process-monitor/src/test/java/org/sonar/process/monitor/JavaCommandTest.java
+++ b/server/sonar-process-monitor/src/test/java/org/sonar/process/monitor/JavaCommandTest.java
@@ -65,8 +65,13 @@ public class JavaCommandTest {
}
@Test
- public void split_java_options() throws Exception {
+ public void add_java_options() throws Exception {
JavaCommand command = new JavaCommand("foo");
+ assertThat(command.getJavaOptions()).isEmpty();
+
+ command.addJavaOptions("");
+ assertThat(command.getJavaOptions()).isEmpty();
+
command.addJavaOptions("-Xmx512m -Xms256m -Dfoo");
assertThat(command.getJavaOptions()).containsOnly("-Xmx512m", "-Xms256m", "-Dfoo");
}