diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-09-10 15:57:00 +0200 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2015-09-10 16:24:35 +0200 |
commit | d716cb1dbbe8a57e5c659c8be3dc0a4dd47d160a (patch) | |
tree | 1d98f216d13222e60ac3a5f7b62c1021d9d41d79 | |
parent | d000d02bf54c1cdd44bfd8b8a5434df1bb4fb4c8 (diff) | |
download | sonarqube-d716cb1dbbe8a57e5c659c8be3dc0a4dd47d160a.tar.gz sonarqube-d716cb1dbbe8a57e5c659c8be3dc0a4dd47d160a.zip |
Do not return empty array of locations in WS
-rw-r--r-- | server/sonar-server/src/main/java/org/sonar/server/computation/issue/TrackerRawInputFactory.java | 10 | ||||
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/issue/ModuleIssues.java | 28 |
2 files changed, 21 insertions, 17 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/TrackerRawInputFactory.java b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/TrackerRawInputFactory.java index f5b79cf4e93..5cce8011da4 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/TrackerRawInputFactory.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/TrackerRawInputFactory.java @@ -133,11 +133,13 @@ public class TrackerRawInputFactory { dbLocationsBuilder.setTextRange(convertTextRange(reportIssue.getTextRange())); } for (BatchReport.Flow flow : reportIssue.getFlowList()) { - DbIssues.Flow.Builder dbFlowBuilder = DbIssues.Flow.newBuilder(); - for (BatchReport.IssueLocation location : flow.getLocationList()) { - dbFlowBuilder.addLocation(convertLocation(location)); + if (flow.getLocationCount()>0) { + DbIssues.Flow.Builder dbFlowBuilder = DbIssues.Flow.newBuilder(); + for (BatchReport.IssueLocation location : flow.getLocationList()) { + dbFlowBuilder.addLocation(convertLocation(location)); + } + dbLocationsBuilder.addFlow(dbFlowBuilder); } - dbLocationsBuilder.addFlow(dbFlowBuilder); } issue.setLocations(dbLocationsBuilder.build()); return issue; diff --git a/sonar-batch/src/main/java/org/sonar/batch/issue/ModuleIssues.java b/sonar-batch/src/main/java/org/sonar/batch/issue/ModuleIssues.java index 9db7fd69fde..f8ade4d0702 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/issue/ModuleIssues.java +++ b/sonar-batch/src/main/java/org/sonar/batch/issue/ModuleIssues.java @@ -109,21 +109,23 @@ public class ModuleIssues { private void applyFlows(Issue issue) { for (Flow flow : issue.flows()) { - flowBuilder.clear(); - for (org.sonar.api.batch.sensor.issue.IssueLocation location : flow.locations()) { - locationBuilder.clear(); - locationBuilder.setComponentRef(componentCache.get(location.inputComponent()).batchId()); - String message = location.message(); - if (message != null) { - locationBuilder.setMsg(message); + if (!flow.locations().isEmpty()) { + flowBuilder.clear(); + for (org.sonar.api.batch.sensor.issue.IssueLocation location : flow.locations()) { + locationBuilder.clear(); + locationBuilder.setComponentRef(componentCache.get(location.inputComponent()).batchId()); + String message = location.message(); + if (message != null) { + locationBuilder.setMsg(message); + } + TextRange textRange = location.textRange(); + if (textRange != null) { + locationBuilder.setTextRange(toProtobufTextRange(textRange)); + } + flowBuilder.addLocation(locationBuilder.build()); } - TextRange textRange = location.textRange(); - if (textRange != null) { - locationBuilder.setTextRange(toProtobufTextRange(textRange)); - } - flowBuilder.addLocation(locationBuilder.build()); + builder.addFlow(flowBuilder.build()); } - builder.addFlow(flowBuilder.build()); } } |