Fix IllegalStateException when running ChangeCleanup

Since I79af43ff2, a new checkState was added when getting the accountId
from a ChangeUpdate. In the case of auto-abandoning, the user is the
Gerrit System so the account id is null. For this reason, an exception
was thrown. The fix is to use the nullable get method instead which
does not check if the id is null.

Change-Id: I60e176cc071d22ac2c4f1f8b4340981bf5709ea2
This commit is contained in:
Alexandre Philbert
2016-05-18 09:15:02 -04:00
parent 4693626108
commit b192ad034f

View File

@@ -71,9 +71,9 @@ public class ChangeMessagesUtil {
public void addChangeMessage(ReviewDb db, ChangeUpdate update,
ChangeMessage changeMessage) throws OrmException {
checkState(
Objects.equals(changeMessage.getAuthor(), update.getAccountId()),
Objects.equals(changeMessage.getAuthor(), update.getNullableAccountId()),
"cannot store change message by %s in update by %s",
changeMessage.getAuthor(), update.getAccountId());
changeMessage.getAuthor(), update.getNullableAccountId());
update.setChangeMessage(changeMessage.getMessage());
update.setTag(changeMessage.getTag());
db.changeMessages().insert(Collections.singleton(changeMessage));