diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2018-02-19 11:33:51 +0100 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2018-02-19 11:33:51 +0100 |
commit | 73a157ba6181a3320dabe1caa452e18806cbd9f9 (patch) | |
tree | d29a4d15367fc0670e77f770a41d4191233b335d | |
parent | 6dabceb176660fbed4195214d39c8f348fbe2c32 (diff) | |
download | sonarqube-73a157ba6181a3320dabe1caa452e18806cbd9f9.tar.gz sonarqube-73a157ba6181a3320dabe1caa452e18806cbd9f9.zip |
Log a better message in case of missing branch
-rw-r--r-- | server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/component/MergeBranchComponentUuids.java | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/component/MergeBranchComponentUuids.java b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/component/MergeBranchComponentUuids.java index 839e59fe863..5d12477afea 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/component/MergeBranchComponentUuids.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/component/MergeBranchComponentUuids.java @@ -22,12 +22,15 @@ package org.sonar.server.computation.task.projectanalysis.component; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Optional; import javax.annotation.CheckForNull; import org.sonar.db.DbClient; import org.sonar.db.DbSession; +import org.sonar.db.component.BranchDto; import org.sonar.db.component.ComponentDto; import org.sonar.server.computation.task.projectanalysis.analysis.AnalysisMetadataHolder; +import static com.google.common.base.Preconditions.checkState; import static org.sonar.db.component.ComponentDto.removeBranchFromKey; /** @@ -56,7 +59,9 @@ public class MergeBranchComponentUuids { uuidsByKey.put(dto.getKey(), dto.uuid()); } - mergeBranchName = dbClient.branchDao().selectByUuid(dbSession, mergeBranchUuid).get().getKey(); + Optional<BranchDto> opt = dbClient.branchDao().selectByUuid(dbSession, mergeBranchUuid); + checkState(opt.isPresent(), "Merge branch '%s' does not exist", mergeBranchUuid); + mergeBranchName = opt.get().getKey(); } } } |