From f127612b203c1664d6eadd6a9e21158c7251f1e4 Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Fri, 28 Jun 2013 15:37:12 +0200 Subject: [PATCH] Fix some quality flaws --- .../src/main/java/org/sonar/runner/api/CommandExecutor.java | 4 +++- .../src/main/java/org/sonar/runner/api/ForkedRunner.java | 4 ++-- .../src/main/java/org/sonar/runner/batch/VersionUtils.java | 3 +++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/sonar-runner-api/src/main/java/org/sonar/runner/api/CommandExecutor.java b/sonar-runner-api/src/main/java/org/sonar/runner/api/CommandExecutor.java index 801c485..f54dbb9 100644 --- a/sonar-runner-api/src/main/java/org/sonar/runner/api/CommandExecutor.java +++ b/sonar-runner-api/src/main/java/org/sonar/runner/api/CommandExecutor.java @@ -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; diff --git a/sonar-runner-api/src/main/java/org/sonar/runner/api/ForkedRunner.java b/sonar-runner-api/src/main/java/org/sonar/runner/api/ForkedRunner.java index d5e28f9..6dbb4bc 100644 --- a/sonar-runner-api/src/main/java/org/sonar/runner/api/ForkedRunner.java +++ b/sonar-runner-api/src/main/java/org/sonar/runner/api/ForkedRunner.java @@ -53,7 +53,7 @@ public class ForkedRunner extends Runner { 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 { } 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 { diff --git a/sonar-runner-batch/src/main/java/org/sonar/runner/batch/VersionUtils.java b/sonar-runner-batch/src/main/java/org/sonar/runner/batch/VersionUtils.java index 01ba896..4f1ce69 100644 --- a/sonar-runner-batch/src/main/java/org/sonar/runner/batch/VersionUtils.java +++ b/sonar-runner-batch/src/main/java/org/sonar/runner/batch/VersionUtils.java @@ -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); } -- 2.39.5