diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-11-30 09:15:38 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-11-30 09:15:38 +0100 |
commit | 12cd5e914608de3ef94b591fb6971ec4206bac99 (patch) | |
tree | 48da5d923f8581d959ac6c93104bf63762ee75f5 /sonar-batch | |
parent | 208886757cf027a931ead00b578a1959f04604dc (diff) | |
download | sonarqube-12cd5e914608de3ef94b591fb6971ec4206bac99.tar.gz sonarqube-12cd5e914608de3ef94b591fb6971ec4206bac99.zip |
Fix quality flaws in BatchUtils
Diffstat (limited to 'sonar-batch')
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/util/BatchUtils.java | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/util/BatchUtils.java b/sonar-batch/src/main/java/org/sonar/batch/util/BatchUtils.java index aa5fbc35ae0..1315cd1d4fb 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/util/BatchUtils.java +++ b/sonar-batch/src/main/java/org/sonar/batch/util/BatchUtils.java @@ -27,7 +27,9 @@ import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; +import javax.annotation.CheckForNull; import javax.annotation.Nullable; +import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -68,13 +70,14 @@ public class BatchUtils { return o.getClass().getName(); } + @CheckForNull public static String getServerVersion() { - InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("sq-version.txt"); + InputStream is = BatchUtils.class.getResourceAsStream("/sq-version.txt"); if (is == null) { LOG.warn("Failed to get SQ version"); return null; } - try (BufferedReader br = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))) { + try (BufferedReader br = IOUtils.toBufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))) { return br.readLine(); } catch (IOException e) { LOG.warn("Failed to get SQ version", e); |