diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/MergeOp.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/MergeOp.java index d7b407b69c..62b404688d 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/git/MergeOp.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/MergeOp.java @@ -35,6 +35,7 @@ import com.google.common.collect.Ordering; import com.google.common.collect.Sets; import com.google.common.hash.Hasher; import com.google.common.hash.Hashing; +import com.google.gerrit.common.Nullable; import com.google.gerrit.common.TimeUtil; import com.google.gerrit.common.data.SubmitRecord; import com.google.gerrit.common.data.SubmitTypeRecord; @@ -608,6 +609,9 @@ public class MergeOp implements AutoCloseable { OpenRepo or = getRepo(branch.getParentKey()); OpenBranch ob = or.getBranch(branch); BranchBatch submitting = toSubmit.get(branch); + checkNotNull(submitting.submitType(), + "null submit type for %s; expected to previously fail fast", + submitting); Set commitsToSubmit = commits(submitting.changes()); ob.mergeTip = new MergeTip(ob.oldTip, commitsToSubmit); SubmitStrategy strategy = createStrategy(or, ob.mergeTip, branch, @@ -687,7 +691,7 @@ public class MergeOp implements AutoCloseable { @AutoValue static abstract class BranchBatch { - abstract SubmitType submitType(); + @Nullable abstract SubmitType submitType(); abstract List changes(); } @@ -710,6 +714,22 @@ public class MergeOp implements AutoCloseable { commits.logProblem(changeId, e); continue; } + + SubmitType st = getSubmitType(cd); + if (st == null) { + commits.logProblem(changeId, "No submit type for change"); + continue; + } + if (submitType == null) { + submitType = st; + choseSubmitTypeFrom = cd; + } else if (st != submitType) { + commits.problem(changeId, String.format( + "Change has submit type %s, but previously chose submit type %s " + + "from change %s in the same batch", + st, submitType, choseSubmitTypeFrom.getId())); + continue; + } if (chg.currentPatchSetId() == null) { String msg = "Missing current patch set on change"; logError(msg + " " + changeId); @@ -772,22 +792,6 @@ public class MergeOp implements AutoCloseable { commits.problem(changeId, mve.getMessage()); continue; } - - SubmitType st = getSubmitType(cd); - if (st == null) { - commits.logProblem(changeId, "No submit type for change"); - continue; - } - if (submitType == null) { - submitType = st; - choseSubmitTypeFrom = cd; - } else if (st != submitType) { - commits.problem(changeId, String.format( - "Change has submit type %s, but previously chose submit type %s " - + "from change %s in the same batch", - st, submitType, choseSubmitTypeFrom.getId())); - continue; - } commit.add(or.canMergeFlag); toSubmit.add(cd); }