aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Hartmann <hartmann.eric@gmail.com>2017-12-29 10:16:55 +0100
committerEric Hartmann <hartmann.eric@gmail.Com>2017-12-29 11:29:03 +0100
commit652bcc1cd8f6cb2d6281694a74300ef3b24fbc11 (patch)
tree375fea8dbd25a0ddf7a2246bf7eef9f4de7921d5
parent3c4af8732eb3df096afbebeda831ff1615107980 (diff)
downloadsonarqube-652bcc1cd8f6cb2d6281694a74300ef3b24fbc11.tar.gz
sonarqube-652bcc1cd8f6cb2d6281694a74300ef3b24fbc11.zip
SONAR-10217 Fix 500 error when branch is incorrect
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/issue/IssueQueryFactory.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionTest.java13
2 files changed, 14 insertions, 1 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/IssueQueryFactory.java b/server/sonar-server/src/main/java/org/sonar/server/issue/IssueQueryFactory.java
index 63974471ac0..1c1c8024b48 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/issue/IssueQueryFactory.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/issue/IssueQueryFactory.java
@@ -394,6 +394,6 @@ public class IssueQueryFactory {
private static void setBranch(IssueQuery.Builder builder, ComponentDto component, @Nullable String branch) {
builder.branchUuid(branch == null ? null : component.projectUuid());
- builder.mainBranch(branch == null || !branch.equals(component.getBranch()));
+ builder.mainBranch(branch == null || component.equals(UNKNOWN_COMPONENT) || !branch.equals(component.getBranch()));
}
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionTest.java
index c8e3753999c..591b68c2886 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionTest.java
@@ -151,6 +151,19 @@ public class SearchActionTest {
"Portfolios are not supported. If this parameter is set, 'projects' must not be set.");
}
+ //SONAR-10217
+ @Test
+ public void empty_search_with_unknown_branch() throws Exception {
+ TestResponse result = ws.newRequest()
+ .setParam("onComponentOnly", "true")
+ .setParam("componentKeys", "foo")
+ .setParam("branch", "bar")
+ .execute();
+
+ assertThat(result).isNotNull();
+ result.assertJson(this.getClass(), "empty_result.json");
+ }
+
@Test
public void empty_search() throws Exception {
TestResponse result = ws.newRequest()