SubmitStrategyOp: Throw IllegalStateException for unexpected submit type

Make the message method throw an IllegalStateException instead of calling
itself with a null CommitMergeStatus that will then be dereferenced and
cause NPE.

Also add a call to checkNotNull on the CommitMergeStatus.

Change-Id: Ie3317c8327166707868d34a51a97457c9d7ac059
This commit is contained in:
David Pursehouse
2016-02-12 10:17:34 +09:00
parent 489842d3c5
commit 18a2b34a54

View File

@@ -412,6 +412,7 @@ abstract class SubmitStrategyOp extends BatchUpdate.Op {
private ChangeMessage message(ChangeContext ctx, CodeReviewCommit commit,
CommitMergeStatus s) {
checkNotNull(s, "CommitMergeStatus may not be null");
String txt = s.getMessage();
if (s == CommitMergeStatus.CLEAN_MERGE) {
return message(ctx, commit.getPatchsetId(), txt + getByAccountName());
@@ -434,7 +435,10 @@ abstract class SubmitStrategyOp extends BatchUpdate.Op {
case REBASE_IF_NECESSARY:
return message(ctx, commit, CommitMergeStatus.CLEAN_REBASE);
default:
return message(ctx, commit, null);
throw new IllegalStateException("unexpected submit type "
+ args.submitType.toString()
+ " for change "
+ commit.change().getId());
}
} else {
throw new IllegalStateException("unexpected status " + s