PostReviewersOp: Check precondition on input state

Change-Id: I91357e943b110ca21db8dede03151490c6fe3a86
This commit is contained in:
Dave Borowitz
2018-10-03 09:04:41 -07:00
parent 42c916189a
commit 4c2f041bb9

View File

@@ -14,8 +14,10 @@
package com.google.gerrit.server.restapi.change;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
import static com.google.gerrit.extensions.client.ReviewerState.CC;
import static com.google.gerrit.extensions.client.ReviewerState.REVIEWER;
import static java.util.stream.Collectors.toList;
import com.google.auto.value.AutoValue;
@@ -124,6 +126,7 @@ public class PostReviewersOp implements BatchUpdateOp {
@Assisted ReviewerState state,
@Assisted @Nullable NotifyHandling notify,
@Assisted ListMultimap<RecipientType, Account.Id> accountsToNotify) {
checkArgument(state == REVIEWER || state == CC, "must be %s or %s: %s", REVIEWER, CC, state);
this.approvalsUtil = approvalsUtil;
this.psUtil = psUtil;
this.reviewerAdded = reviewerAdded;