summaryrefslogtreecommitdiffstats
path: root/sonar-batch/src/main
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2015-10-01 13:17:04 +0200
committerDuarte Meneses <duarte.meneses@sonarsource.com>2015-10-01 13:27:26 +0200
commit964ce2999b7bef53d78c42210b8284b369241603 (patch)
tree845a055789db0e5b668762697b5fcd8c1e6e1270 /sonar-batch/src/main
parent5c05eec1d21420ba6ca423064fbd493202770771 (diff)
downloadsonarqube-964ce2999b7bef53d78c42210b8284b369241603.tar.gz
sonarqube-964ce2999b7bef53d78c42210b8284b369241603.zip
Fix call to /batch/project WS and handling of errors
Diffstat (limited to 'sonar-batch/src/main')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/repository/DefaultProjectRepositoriesLoader.java22
1 files changed, 20 insertions, 2 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/repository/DefaultProjectRepositoriesLoader.java b/sonar-batch/src/main/java/org/sonar/batch/repository/DefaultProjectRepositoriesLoader.java
index fd0b0e0e4ec..6f4f10c74fa 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/repository/DefaultProjectRepositoriesLoader.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/repository/DefaultProjectRepositoriesLoader.java
@@ -19,13 +19,18 @@
*/
package org.sonar.batch.repository;
+import org.sonar.api.utils.HttpDownloader.HttpException;
+
import com.google.common.collect.HashBasedTable;
import com.google.common.collect.Table;
+
import java.io.IOException;
import java.io.InputStream;
import java.util.Date;
import java.util.Map;
+
import javax.annotation.Nullable;
+
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.mutable.MutableBoolean;
import org.slf4j.Logger;
@@ -55,7 +60,11 @@ public class DefaultProjectRepositoriesLoader implements ProjectRepositoriesLoad
}
return processStream(result.get(), projectKey);
} catch (IllegalStateException e) {
- LOG.debug("Couldn't get project repositories - continuing without it", e);
+ if (shouldThrow(e)) {
+ throw e;
+ }
+
+ LOG.debug("Project repository not available - continuing without it", e);
return new ProjectRepositories();
}
}
@@ -66,11 +75,20 @@ public class DefaultProjectRepositoriesLoader implements ProjectRepositoriesLoad
builder.append(BATCH_PROJECT_URL)
.append("?key=").append(BatchUtils.encodeForUrl(projectKey));
if (issuesMode) {
- builder.append("&issues=true");
+ builder.append("&issues_mode=true");
}
return builder.toString();
}
+ private static boolean shouldThrow(Exception e) {
+ if (e.getCause() != null && e.getCause() instanceof HttpException) {
+ HttpException http = (HttpException) e.getCause();
+ return http.getResponseCode() != 404;
+ }
+
+ return false;
+ }
+
private static ProjectRepositories processStream(InputStream is, String projectKey) {
try {
WsProjectResponse response = WsProjectResponse.parseFrom(is);