aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ServerClient.java
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2013-07-11 12:22:50 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2013-07-11 12:57:52 +0200
commit195d307840e5e4aaf6d64fab2227b5d8230108b3 (patch)
treedd28f7024e1c0985952415ade1ef3f01b8983342 /sonar-batch/src/main/java/org/sonar/batch/bootstrap/ServerClient.java
parentac46595adb827cbc615fa6cb2702d00f7bf41937 (diff)
downloadsonarqube-195d307840e5e4aaf6d64fab2227b5d8230108b3.tar.gz
sonarqube-195d307840e5e4aaf6d64fab2227b5d8230108b3.zip
SONAR-4488 Increase timeout for /batch_bootstrap/db
Diffstat (limited to 'sonar-batch/src/main/java/org/sonar/batch/bootstrap/ServerClient.java')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/ServerClient.java18
1 files changed, 13 insertions, 5 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ServerClient.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ServerClient.java
index 16028be1299..b04bd67a360 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ServerClient.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ServerClient.java
@@ -58,8 +58,12 @@ public class ServerClient implements BatchComponent {
}
public void download(String pathStartingWithSlash, File toFile) {
+ download(pathStartingWithSlash, toFile, null);
+ }
+
+ public void download(String pathStartingWithSlash, File toFile, Integer readTimeoutMillis) {
try {
- InputSupplier<InputStream> inputSupplier = doRequest(pathStartingWithSlash);
+ InputSupplier<InputStream> inputSupplier = doRequest(pathStartingWithSlash, readTimeoutMillis);
Files.copy(inputSupplier, toFile);
} catch (HttpDownloader.HttpException he) {
throw handleHttpException(he);
@@ -73,7 +77,11 @@ public class ServerClient implements BatchComponent {
}
public String request(String pathStartingWithSlash, boolean wrapHttpException) {
- InputSupplier<InputStream> inputSupplier = doRequest(pathStartingWithSlash);
+ return request(pathStartingWithSlash, wrapHttpException, null);
+ }
+
+ public String request(String pathStartingWithSlash, boolean wrapHttpException, Integer timeoutMillis) {
+ InputSupplier<InputStream> inputSupplier = doRequest(pathStartingWithSlash, timeoutMillis);
try {
return IOUtils.toString(inputSupplier.getInput(), "UTF-8");
} catch (HttpDownloader.HttpException e) {
@@ -83,7 +91,7 @@ public class ServerClient implements BatchComponent {
}
}
- private InputSupplier<InputStream> doRequest(String pathStartingWithSlash) {
+ private InputSupplier<InputStream> doRequest(String pathStartingWithSlash, Integer timeoutMillis) {
Preconditions.checkArgument(pathStartingWithSlash.startsWith("/"), "Path must start with slash /");
String path = StringEscapeUtils.escapeHtml(pathStartingWithSlash);
@@ -91,9 +99,9 @@ public class ServerClient implements BatchComponent {
try {
InputSupplier<InputStream> inputSupplier;
if (Strings.isNullOrEmpty(getLogin())) {
- inputSupplier = downloader.newInputSupplier(uri);
+ inputSupplier = downloader.newInputSupplier(uri, timeoutMillis);
} else {
- inputSupplier = downloader.newInputSupplier(uri, getLogin(), getPassword());
+ inputSupplier = downloader.newInputSupplier(uri, getLogin(), getPassword(), timeoutMillis);
}
return inputSupplier;
} catch (Exception e) {