diff options
author | Michal Duda <michal.duda@sonarsource.com> | 2020-04-08 19:38:02 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2020-04-14 20:04:04 +0000 |
commit | d662d0c0269e1a12da0c3ecdb8f9d33b765ccdcc (patch) | |
tree | 7ec6d738cc8516bf42f42552a64f1cdbb0307a37 /server/sonar-webserver | |
parent | ab6328a769fbe531464fc9dd77cc64efc72ba390 (diff) | |
download | sonarqube-d662d0c0269e1a12da0c3ecdb8f9d33b765ccdcc.tar.gz sonarqube-d662d0c0269e1a12da0c3ecdb8f9d33b765ccdcc.zip |
SONAR-13272 fix issue with setting some properties through env variables
Diffstat (limited to 'server/sonar-webserver')
-rw-r--r-- | server/sonar-webserver/src/main/java/org/sonar/server/app/TomcatConnectors.java | 12 | ||||
-rw-r--r-- | server/sonar-webserver/src/main/java/org/sonar/server/app/TomcatContexts.java | 7 |
2 files changed, 11 insertions, 8 deletions
diff --git a/server/sonar-webserver/src/main/java/org/sonar/server/app/TomcatConnectors.java b/server/sonar-webserver/src/main/java/org/sonar/server/app/TomcatConnectors.java index 5a43767f460..dc55d7bbd9c 100644 --- a/server/sonar-webserver/src/main/java/org/sonar/server/app/TomcatConnectors.java +++ b/server/sonar-webserver/src/main/java/org/sonar/server/app/TomcatConnectors.java @@ -25,6 +25,10 @@ import org.apache.catalina.startup.Tomcat; import org.sonar.process.Props; import static java.lang.String.format; +import static org.sonar.process.ProcessProperties.Property.WEB_HOST; +import static org.sonar.process.ProcessProperties.Property.WEB_HTTP_ACCEPT_COUNT; +import static org.sonar.process.ProcessProperties.Property.WEB_HTTP_MAX_THREADS; +import static org.sonar.process.ProcessProperties.Property.WEB_HTTP_MIN_THREADS; /** * Configuration of Tomcat connectors @@ -53,7 +57,7 @@ class TomcatConnectors { Connector connector = new Connector(HTTP_PROTOCOL); connector.setURIEncoding("UTF-8"); - connector.setProperty("address", props.value("sonar.web.host", "0.0.0.0")); + connector.setProperty("address", props.value(WEB_HOST.getKey(), "0.0.0.0")); connector.setProperty("socket.soReuseAddress", "true"); // see https://tomcat.apache.org/tomcat-8.5-doc/config/http.html connector.setProperty("relaxedQueryChars", "\"<>[\\]^`{|}"); @@ -75,9 +79,9 @@ class TomcatConnectors { private static void configurePool(Props props, Connector connector) { connector.setProperty("acceptorThreadCount", String.valueOf(2)); - connector.setProperty("minSpareThreads", String.valueOf(props.valueAsInt("sonar.web.http.minThreads", 5))); - connector.setProperty("maxThreads", String.valueOf(props.valueAsInt("sonar.web.http.maxThreads", 50))); - connector.setProperty("acceptCount", String.valueOf(props.valueAsInt("sonar.web.http.acceptCount", 25))); + connector.setProperty("minSpareThreads", String.valueOf(props.valueAsInt(WEB_HTTP_MIN_THREADS.getKey(), 5))); + connector.setProperty("maxThreads", String.valueOf(props.valueAsInt(WEB_HTTP_MAX_THREADS.getKey(), 50))); + connector.setProperty("acceptCount", String.valueOf(props.valueAsInt(WEB_HTTP_ACCEPT_COUNT.getKey(), 25))); } private static void configureCompression(Connector connector) { diff --git a/server/sonar-webserver/src/main/java/org/sonar/server/app/TomcatContexts.java b/server/sonar-webserver/src/main/java/org/sonar/server/app/TomcatContexts.java index 48eb59b495b..b1afee1dd83 100644 --- a/server/sonar-webserver/src/main/java/org/sonar/server/app/TomcatContexts.java +++ b/server/sonar-webserver/src/main/java/org/sonar/server/app/TomcatContexts.java @@ -32,6 +32,7 @@ import org.sonar.process.Props; import static java.lang.String.format; import static org.sonar.process.ProcessProperties.Property.PATH_DATA; import static org.sonar.process.ProcessProperties.Property.PATH_HOME; +import static org.sonar.process.ProcessProperties.Property.WEB_CONTEXT; /** * Configures Tomcat contexts: @@ -41,8 +42,6 @@ import static org.sonar.process.ProcessProperties.Property.PATH_HOME; * </ul> */ public class TomcatContexts { - - private static final String PROPERTY_CONTEXT = "sonar.web.context"; private static final String WEB_DEPLOY_PATH_RELATIVE_TO_DATA_DIR = "web/deploy"; private final Fs fs; @@ -68,11 +67,11 @@ public class TomcatContexts { } static String getContextPath(Props props) { - String context = props.value(PROPERTY_CONTEXT, ""); + String context = props.value(WEB_CONTEXT.getKey(), ""); if ("/".equals(context)) { context = ""; } else if (!"".equals(context) && context != null && !context.startsWith("/")) { - throw MessageException.of(format("Value of '%s' must start with a forward slash: '%s'", PROPERTY_CONTEXT, context)); + throw MessageException.of(format("Value of '%s' must start with a forward slash: '%s'", WEB_CONTEXT.getKey(), context)); } return context; } |