aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-runner-impl/src/main/java/org/sonar/runner/impl
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2014-04-07 17:12:26 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2014-04-07 17:12:26 +0200
commita9bf502a052d2edc80526521de7407b43d751973 (patch)
tree09a572f4ac43a467c040efd332366942036290d1 /sonar-runner-impl/src/main/java/org/sonar/runner/impl
parent20f838228f687a6f6cddc79838956601b23a229c (diff)
downloadsonar-scanner-cli-a9bf502a052d2edc80526521de7407b43d751973.tar.gz
sonar-scanner-cli-a9bf502a052d2edc80526521de7407b43d751973.zip
Fix some quality flaws and update coverage
Diffstat (limited to 'sonar-runner-impl/src/main/java/org/sonar/runner/impl')
-rw-r--r--sonar-runner-impl/src/main/java/org/sonar/runner/impl/BatchLauncher.java3
-rw-r--r--sonar-runner-impl/src/main/java/org/sonar/runner/impl/ServerConnection.java11
-rw-r--r--sonar-runner-impl/src/main/java/org/sonar/runner/impl/package-info.java3
3 files changed, 10 insertions, 7 deletions
diff --git a/sonar-runner-impl/src/main/java/org/sonar/runner/impl/BatchLauncher.java b/sonar-runner-impl/src/main/java/org/sonar/runner/impl/BatchLauncher.java
index 74d0a30..49383ce 100644
--- a/sonar-runner-impl/src/main/java/org/sonar/runner/impl/BatchLauncher.java
+++ b/sonar-runner-impl/src/main/java/org/sonar/runner/impl/BatchLauncher.java
@@ -66,7 +66,7 @@ public class BatchLauncher {
* @return the {@link org.sonar.runner.batch.IsolatedLauncher} instance for unit tests
*/
Object doExecute(final JarDownloader jarDownloader, final ServerVersion serverVersion, final Properties props, final List<Object> extensions) {
- Object launcher = AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ return AccessController.doPrivileged(new PrivilegedAction<Object>() {
public Object run() {
List<File> jarFiles = jarDownloader.checkVersionAndDownload();
String[][] maskRules = getMaskRules(props);
@@ -97,7 +97,6 @@ public class BatchLauncher {
}
}
});
- return launcher;
}
}
diff --git a/sonar-runner-impl/src/main/java/org/sonar/runner/impl/ServerConnection.java b/sonar-runner-impl/src/main/java/org/sonar/runner/impl/ServerConnection.java
index 116ba4f..b68e480 100644
--- a/sonar-runner-impl/src/main/java/org/sonar/runner/impl/ServerConnection.java
+++ b/sonar-runner-impl/src/main/java/org/sonar/runner/impl/ServerConnection.java
@@ -27,12 +27,15 @@ import java.io.IOException;
import java.net.ConnectException;
import java.net.URL;
import java.net.UnknownHostException;
+import java.text.MessageFormat;
import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
class ServerConnection {
+ private static final String SONAR_SERVER_CAN_NOT_BE_REACHED = "Sonar server ''{0}'' can not be reached";
+ private static final String STATUS_RETURNED_BY_URL_IS_INVALID = "Status returned by url : ''{0}'' is invalid : {1}";
static final int CONNECT_TIMEOUT_MILLISECONDS = 30000;
static final int READ_TIMEOUT_MILLISECONDS = 60000;
private static final Pattern CHARSET_PATTERN = Pattern.compile("(?i)\\bcharset=\\s*\"?([^\\s;\"]*)");
@@ -65,13 +68,13 @@ class ServerConnection {
Logs.debug("Download " + fullUrl + " to " + toFile.getAbsolutePath());
HttpRequest httpRequest = newHttpRequest(new URL(fullUrl));
if (!httpRequest.ok()) {
- throw new IOException("Status returned by url : '" + fullUrl + "' is invalid : " + httpRequest.code());
+ throw new IOException(MessageFormat.format(STATUS_RETURNED_BY_URL_IS_INVALID, fullUrl, httpRequest.code()));
}
httpRequest.receive(toFile);
} catch (Exception e) {
if (e.getCause() instanceof ConnectException || e.getCause() instanceof UnknownHostException) {
- Logs.error("Sonar server '" + serverUrl + "' can not be reached");
+ Logs.error(MessageFormat.format(SONAR_SERVER_CAN_NOT_BE_REACHED, serverUrl));
}
FileUtils.deleteQuietly(toFile);
throw new IllegalStateException("Fail to download: " + fullUrl, e);
@@ -88,13 +91,13 @@ class ServerConnection {
charset = "UTF-8";
}
if (!httpRequest.ok()) {
- throw new IOException("Status returned by url : '" + fullUrl + "' is invalid : " + httpRequest.code());
+ throw new IOException(MessageFormat.format(STATUS_RETURNED_BY_URL_IS_INVALID, fullUrl, httpRequest.code()));
}
return httpRequest.body(charset);
} catch (HttpRequest.HttpRequestException e) {
if (e.getCause() instanceof ConnectException || e.getCause() instanceof UnknownHostException) {
- Logs.error("Sonar server '" + serverUrl + "' can not be reached");
+ Logs.error(MessageFormat.format(SONAR_SERVER_CAN_NOT_BE_REACHED, serverUrl));
}
throw e;
diff --git a/sonar-runner-impl/src/main/java/org/sonar/runner/impl/package-info.java b/sonar-runner-impl/src/main/java/org/sonar/runner/impl/package-info.java
index 6bdeba8..eff9ce5 100644
--- a/sonar-runner-impl/src/main/java/org/sonar/runner/impl/package-info.java
+++ b/sonar-runner-impl/src/main/java/org/sonar/runner/impl/package-info.java
@@ -18,4 +18,5 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
*/
@javax.annotation.ParametersAreNonnullByDefault
-package org.sonar.runner.impl; \ No newline at end of file
+package org.sonar.runner.impl;
+