]> source.dussan.org Git - sonar-scanner-cli.git/commitdiff
Fix some quality flaws
authorJulien HENRY <julien.henry@sonarsource.com>
Fri, 28 Jun 2013 13:37:12 +0000 (15:37 +0200)
committerJulien HENRY <julien.henry@sonarsource.com>
Fri, 28 Jun 2013 13:37:12 +0000 (15:37 +0200)
sonar-runner-api/src/main/java/org/sonar/runner/api/CommandExecutor.java
sonar-runner-api/src/main/java/org/sonar/runner/api/ForkedRunner.java
sonar-runner-batch/src/main/java/org/sonar/runner/batch/VersionUtils.java

index 801c485f0e1328ed67b6f2a2bbdb6dfc19631968..f54dbb9512b6c830d1fcf7f1c8d420ee6a9cba3a 100644 (file)
@@ -21,6 +21,8 @@ package org.sonar.runner.api;
 
 import org.apache.commons.io.IOUtils;
 
+import javax.annotation.Nullable;
+
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStream;
@@ -50,7 +52,7 @@ class CommandExecutor {
     return INSTANCE;
   }
 
-  int execute(Command command, StreamConsumer stdOut, StreamConsumer stdErr, long timeoutMilliseconds, ProcessMonitor processMonitor) {
+  int execute(Command command, StreamConsumer stdOut, StreamConsumer stdErr, long timeoutMilliseconds, @Nullable ProcessMonitor processMonitor) {
     ExecutorService executorService = null;
     Process process = null;
     StreamGobbler outputGobbler = null;
index d5e28f99347a33f4ee7fe25f6e148d07d96d8fd5..6dbb4bce19d372a8452e3226792ca12157a1182f 100644 (file)
@@ -53,7 +53,7 @@ public class ForkedRunner extends Runner<ForkedRunner> {
 
   private ProcessMonitor processMonitor;
 
-  ForkedRunner(JarExtractor jarExtractor, CommandExecutor commandExecutor, ProcessMonitor processMonitor) {
+  ForkedRunner(JarExtractor jarExtractor, CommandExecutor commandExecutor, @Nullable ProcessMonitor processMonitor) {
     this.jarExtractor = jarExtractor;
     this.commandExecutor = commandExecutor;
     this.processMonitor = processMonitor;
@@ -192,7 +192,7 @@ public class ForkedRunner extends Runner<ForkedRunner> {
     }
     int status = commandExecutor.execute(forkCommand.command, stdOut, stdErr, ONE_DAY_IN_MILLISECONDS, processMonitor);
     if (status != 0) {
-      if (processMonitor.stop()) {
+      if (processMonitor != null && processMonitor.stop()) {
         stdOut.consumeLine(String.format("SonarQube Runner was stopped [status=%s]", status));
       }
       else {
index 01ba89659fafbaa54742f038e781e63892f191e0..4f1ce69271d8651d6f8c3d14d47d412d53b545a9 100644 (file)
@@ -23,6 +23,9 @@ class VersionUtils {
 
   private static final String[] LESS_THAN_3_7 = {"0", "1", "2", "3.0", "3.1", "3.2", "3.3", "3.4", "3.5", "3.6"};
 
+  private VersionUtils() {
+  }
+
   static boolean isLessThan37(String version) {
     return inVersions(version, LESS_THAN_3_7);
   }