diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2015-03-12 18:27:13 +0100 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2015-03-12 18:27:13 +0100 |
commit | d25ad7cf7e19b229d4f9059c6f4550d33ce50474 (patch) | |
tree | 233f41faa973c0089b1ef7799101566e61e84714 /sonar-batch/src/main/java | |
parent | 81694b1f98c68e84d893205bc0a416544cf1aac4 (diff) | |
download | sonarqube-d25ad7cf7e19b229d4f9059c6f4550d33ce50474.tar.gz sonarqube-d25ad7cf7e19b229d4f9059c6f4550d33ce50474.zip |
SONAR-6273 Really fix NPE when working on projects with branches
Diffstat (limited to 'sonar-batch/src/main/java')
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/report/ComponentsPublisher.java | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/report/ComponentsPublisher.java b/sonar-batch/src/main/java/org/sonar/batch/report/ComponentsPublisher.java index 950fa923ddf..186f4368d6e 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/report/ComponentsPublisher.java +++ b/sonar-batch/src/main/java/org/sonar/batch/report/ComponentsPublisher.java @@ -92,7 +92,7 @@ public class ComponentsPublisher implements ReportPublisher { builder.addChildRefs(child.batchId()); } if (ResourceUtils.isProject(r)) { - ProjectDefinition def = reactor.getProject(r.getKey()); + ProjectDefinition def = getProjectDefinition(reactor, r.getKey()); ComponentLink.Builder linkBuilder = ComponentLink.newBuilder(); writeProjectLink(builder, def, linkBuilder, CoreProperties.LINKS_HOME_PAGE, ComponentLinkType.HOME); @@ -108,6 +108,15 @@ public class ComponentsPublisher implements ReportPublisher { } } + private ProjectDefinition getProjectDefinition(ProjectReactor reactor, String keyWithBranch) { + for (ProjectDefinition p : reactor.getProjects()) { + if (keyWithBranch.equals(p.getKeyWithBranch())) { + return p; + } + } + return null; + } + private void writeProjectLink(BatchReport.Component.Builder componentBuilder, ProjectDefinition def, ComponentLink.Builder linkBuilder, String linkProp, ComponentLinkType linkType) { String link = def.properties().get(linkProp); |