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