]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5709 Add properties sonar.search.javaAdditionalOpts and sonar.web.javaAdditiona...
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Wed, 8 Oct 2014 10:29:44 +0000 (12:29 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Wed, 8 Oct 2014 10:30:07 +0000 (12:30 +0200)
debug-server.sh
server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/JavaCommand.java
server/sonar-process-monitor/src/test/java/org/sonar/process/monitor/JavaCommandTest.java
sonar-application/src/main/assembly/conf/sonar.properties
sonar-application/src/main/java/org/sonar/application/App.java
sonar-application/src/main/java/org/sonar/application/DefaultSettings.java

index 5dadb3becab8ccddfa2a55a268505d6ba2749278..1d1549d9c4d11fd0792fd66926427671ce4a5ef0 100755 (executable)
@@ -7,4 +7,4 @@ if ! ls sonarqube-*/bin/sonar-application*.jar &> /dev/null; then
 fi
 
 cd sonarqube-*
-java -jar ./lib/sonar-application*.jar -Dsonar.web.javaOpts=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
\ No newline at end of file
+java -jar ./lib/sonar-application*.jar -Dsonar.web.javaAdditionalOpts=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
index 7750b6deb35384514aed80e5c21b395f36939c4e..76abf52debafbd6a6e7d2cdc2847d1b6465a40fd 100644 (file)
@@ -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;
   }
 
index fbfbad11b54846642fe1d297b132531d8928791a..689f061ff06a4e2aa4187841f2833d84beee3b73 100644 (file)
@@ -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");
   }
index f14700b3592e9447b7f7250a4989e4f5f7b86136..ff26347346f94e433b465ec80022beca4a8cf35c 100644 (file)
@@ -69,6 +69,9 @@ sonar.jdbc.timeBetweenEvictionRunsMillis=30000
 #sonar.web.javaOpts=-Xmx768m -XX:MaxPermSize=160m -XX:+HeapDumpOnOutOfMemoryError \
 #  -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djruby.management.enabled=false
 
+# Same as previous property, but allows to not repeat all settings like -Djava.awt.headless=true
+#sonar.web.javaAdditionalOpts=
+
 # Binding IP address. For servers with more than one IP address, this property specifies which
 # address will be used for listening on the specified ports.
 # By default, ports will be used on all IP addresses associated with the server.
@@ -173,6 +176,9 @@ sonar.jdbc.timeBetweenEvictionRunsMillis=30000
 #  -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError \
 #  -Djava.awt.headless=true
 
+# Same as previous property, but allows to not repeat all settings like -Djava.awt.headless=true
+#sonar.search.javaAdditionalOpts=
+
 # Elasticsearch port. Default is 9001. Use 0 to get a free port.
 # This port must be private and must not be exposed to the Internet.
 #sonar.search.port=9001
index 502cf561394b0926844c2302964b58c5fe602105..ff8016fabc8d7a92b8d6ff23bd0084d840004230 100644 (file)
@@ -70,7 +70,8 @@ public class App implements Stoppable {
     JavaCommand elasticsearch = new JavaCommand("search");
     elasticsearch
       .setWorkDir(homeDir)
-      .addJavaOptions(props.value(DefaultSettings.SEARCH_JAVA_OPTS))
+      .addJavaOptions(props.nonNullValue(DefaultSettings.SEARCH_JAVA_OPTS))
+      .addJavaOptions(props.nonNullValue(DefaultSettings.SEARCH_JAVA_ADDITIONAL_OPTS))
       .setTempDir(tempDir.getAbsoluteFile())
       .setClassName("org.sonar.search.SearchServer")
       .setArguments(props.rawProperties())
@@ -83,6 +84,7 @@ public class App implements Stoppable {
       JavaCommand webServer = new JavaCommand("web")
         .setWorkDir(homeDir)
         .addJavaOptions(props.nonNullValue(DefaultSettings.WEB_JAVA_OPTS))
+        .addJavaOptions(props.nonNullValue(DefaultSettings.WEB_JAVA_ADDITIONAL_OPTS))
         .setTempDir(tempDir.getAbsoluteFile())
         // required for logback tomcat valve
         .setEnvVariable("sonar.path.logs", props.nonNullValue("sonar.path.logs"))
index 701249f5f63ce8da8e716d77cefc7940826d04d2..4a9367894998cebc31f7c469c53215b67a689c63 100644 (file)
@@ -36,7 +36,9 @@ class DefaultSettings {
   static final String CLUSTER_NODE_NAME = "sonar.node.name";
   static final String SEARCH_PORT = "sonar.search.port";
   static final String SEARCH_JAVA_OPTS = "sonar.search.javaOpts";
+  static final String SEARCH_JAVA_ADDITIONAL_OPTS = "sonar.search.javaAdditionalOpts";
   static final String WEB_JAVA_OPTS = "sonar.web.javaOpts";
+  static final String WEB_JAVA_ADDITIONAL_OPTS = "sonar.web.javaAdditionalOpts";
   static final String JDBC_URL = "sonar.jdbc.url";
   static final String JDBC_LOGIN = "sonar.jdbc.username";
   static final String JDBC_PASSWORD = "sonar.jdbc.password";
@@ -70,9 +72,11 @@ class DefaultSettings {
     defaults.put(SEARCH_JAVA_OPTS, "-Xmx256m -Xms256m -Xss256k -Djava.net.preferIPv4Stack=true " +
       "-XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly " +
       "-XX:+HeapDumpOnOutOfMemoryError -Djava.awt.headless=true");
+    defaults.put(SEARCH_JAVA_ADDITIONAL_OPTS, "");
     defaults.put(CLUSTER_NODE_NAME, "sonar-" + System.currentTimeMillis());
     defaults.put(WEB_JAVA_OPTS, "-Xmx768m -XX:MaxPermSize=160m -XX:+HeapDumpOnOutOfMemoryError -Djava.net.preferIPv4Stack=true " +
       "-Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djruby.management.enabled=false");
+    defaults.put(WEB_JAVA_ADDITIONAL_OPTS, "");
     defaults.put(JDBC_URL, "jdbc:h2:tcp://localhost:9092/sonar");
     defaults.put(JDBC_LOGIN, "sonar");
     defaults.put(JDBC_PASSWORD, "sonar");