diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-08-26 18:28:55 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-08-26 18:45:51 +0200 |
commit | c2d7e44f722f3c14af036553fdc001408f47343a (patch) | |
tree | bd11dfa755ee93946cc5e5197fcadd271aad83f3 /sonar-application/src/main | |
parent | cd5e247daf7096f3c62ada0c65d2657b954195c1 (diff) | |
download | sonarqube-c2d7e44f722f3c14af036553fdc001408f47343a.tar.gz sonarqube-c2d7e44f722f3c14af036553fdc001408f47343a.zip |
Fix some quality flaws
Diffstat (limited to 'sonar-application/src/main')
4 files changed, 17 insertions, 24 deletions
diff --git a/sonar-application/src/main/java/org/sonar/application/App.java b/sonar-application/src/main/java/org/sonar/application/App.java index 43c192bf716..784d75ef299 100644 --- a/sonar-application/src/main/java/org/sonar/application/App.java +++ b/sonar-application/src/main/java/org/sonar/application/App.java @@ -26,7 +26,6 @@ import org.slf4j.LoggerFactory; import org.sonar.process.JmxUtils; import org.sonar.process.MinimumViableSystem; import org.sonar.process.Monitor; -import org.sonar.process.MonitoredProcess; import org.sonar.process.ProcessLogging; import org.sonar.process.ProcessMXBean; import org.sonar.process.ProcessUtils; @@ -35,8 +34,6 @@ import org.sonar.process.Props; import org.sonar.search.SearchServer; import java.io.File; -import java.io.IOException; -import java.net.URISyntaxException; import java.util.Properties; /** @@ -60,13 +57,13 @@ public class App implements ProcessMXBean { monitor.start(); - File homeDir = props.fileOf("sonar.path.home"); - File tempDir = props.fileOf("sonar.path.temp"); + File homeDir = props.nonNullValueAsFile("sonar.path.home"); + File tempDir = props.nonNullValueAsFile("sonar.path.temp"); elasticsearch = new ProcessWrapper(JmxUtils.SEARCH_SERVER_NAME); elasticsearch .setWorkDir(homeDir) - .setJmxPort(props.intOf(DefaultSettings.SEARCH_JMX_PORT)) - .addJavaOpts(props.of(DefaultSettings.SEARCH_JAVA_OPTS)) + .setJmxPort(props.valueAsInt(DefaultSettings.SEARCH_JMX_PORT)) + .addJavaOpts(props.value(DefaultSettings.SEARCH_JAVA_OPTS)) .setTempDirectory(tempDir.getAbsoluteFile()) .setClassName("org.sonar.search.SearchServer") .addProperties(props.rawProperties()) @@ -78,19 +75,19 @@ public class App implements ProcessMXBean { logger.info("search server is up"); // do not yet start SQ in cluster mode. See SONAR-5483 & SONAR-5391 - if (StringUtils.isEmpty(props.of(DefaultSettings.CLUSTER_MASTER, null))) { + if (StringUtils.isEmpty(props.value(DefaultSettings.CLUSTER_MASTER))) { server = new ProcessWrapper(JmxUtils.WEB_SERVER_NAME) .setWorkDir(homeDir) - .setJmxPort(props.intOf(DefaultSettings.WEB_JMX_PORT)) - .addJavaOpts(props.of(DefaultSettings.WEB_JAVA_OPTS)) + .setJmxPort(props.valueAsInt(DefaultSettings.WEB_JMX_PORT)) + .addJavaOpts(props.nonNullValue(DefaultSettings.WEB_JAVA_OPTS)) .setTempDirectory(tempDir.getAbsoluteFile()) - // required for logback tomcat valve - .setLogDir(props.fileOf("sonar.path.logs")) + // required for logback tomcat valve + .setLogDir(props.nonNullValueAsFile("sonar.path.logs")) .setClassName("org.sonar.server.app.WebServer") .addProperties(props.rawProperties()) .addClasspath("./lib/common/*") .addClasspath("./lib/server/*"); - String driverPath = props.of(JdbcSettings.PROPERTY_DRIVER_PATH); + String driverPath = props.value(JdbcSettings.PROPERTY_DRIVER_PATH); if (driverPath != null) { server.addClasspath(driverPath); } @@ -150,27 +147,23 @@ public class App implements ProcessMXBean { } public static void main(String[] args) { - new MinimumViableSystem().check(); CommandLineParser cli = new CommandLineParser(); Properties rawProperties = cli.parseArguments(args); - Props props = null; + Props props; try { props = new PropsBuilder(rawProperties, new JdbcSettings()).build(); new ProcessLogging().configure(props, "/org/sonar/application/logback.xml"); - } catch (IOException e) { - throw new IllegalStateException(e.getMessage()); - } catch (URISyntaxException e) { - throw new IllegalStateException(e.getMessage()); + } catch (Exception e) { + throw new IllegalStateException(e); } App app = new App(); - try { // start and wait for shutdown command if (props.contains(SearchServer.ES_CLUSTER_INET)) { - LoggerFactory.getLogger(App.class).info("SonarQube slave configured to join SonarQube master : {}", props.of(SearchServer.ES_CLUSTER_INET)); + LoggerFactory.getLogger(App.class).info("SonarQube slave configured to join SonarQube master : {}", props.value(SearchServer.ES_CLUSTER_INET)); } app.start(props); } catch (InterruptedException e) { diff --git a/sonar-application/src/main/java/org/sonar/application/DefaultSettings.java b/sonar-application/src/main/java/org/sonar/application/DefaultSettings.java index e6d737487ac..0a85182cc21 100644 --- a/sonar-application/src/main/java/org/sonar/application/DefaultSettings.java +++ b/sonar-application/src/main/java/org/sonar/application/DefaultSettings.java @@ -55,7 +55,7 @@ class DefaultSettings { // init ports for (Map.Entry<String, Integer> entry : defaultPorts().entrySet()) { String key = entry.getKey(); - int port = props.intOf(key, -1); + int port = props.valueAsInt(key, -1); if (port == -1) { // default port props.set(key, String.valueOf((int) entry.getValue())); diff --git a/sonar-application/src/main/java/org/sonar/application/JdbcSettings.java b/sonar-application/src/main/java/org/sonar/application/JdbcSettings.java index 300de2421dd..ff88ae0f9c0 100644 --- a/sonar-application/src/main/java/org/sonar/application/JdbcSettings.java +++ b/sonar-application/src/main/java/org/sonar/application/JdbcSettings.java @@ -50,7 +50,7 @@ public class JdbcSettings { } public void checkAndComplete(File homeDir, Props props) { - String url = props.of(DefaultSettings.JDBC_URL); + String url = props.value(DefaultSettings.JDBC_URL); Provider provider = driverProvider(url); checkUrlParameters(provider, url); String driverPath = driverPath(homeDir, provider); diff --git a/sonar-application/src/main/java/org/sonar/application/PropsBuilder.java b/sonar-application/src/main/java/org/sonar/application/PropsBuilder.java index 0793a314163..f736658db7b 100644 --- a/sonar-application/src/main/java/org/sonar/application/PropsBuilder.java +++ b/sonar-application/src/main/java/org/sonar/application/PropsBuilder.java @@ -111,7 +111,7 @@ class PropsBuilder { } private File configureDir(Props props, String propKey, String defaultRelativePath) { - String path = props.of(propKey, defaultRelativePath); + String path = props.value(propKey, defaultRelativePath); File d = new File(path); if (!d.isAbsolute()) { d = new File(homeDir, path); |