Fix ChangeRebuilderImpl with null account IDs

The Event comparator had a NPE when used with a null account ID,
which is otherwise supported. This only shows up after comparing a
few more fields, which may be why it hasn't shown up yet. (Or maybe
we didn't have any test cases at all with null IDs.)

Change-Id: I3723b0c9a90eac7ddd9b283d1e332ef92667c63b
This commit is contained in:
Dave Borowitz
2016-04-14 20:08:06 -04:00
parent ccc1ef19b1
commit c7cb3dd131
3 changed files with 38 additions and 2 deletions

View File

@@ -42,6 +42,7 @@ import com.google.gerrit.reviewdb.client.PatchLineComment.Status;
import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.reviewdb.client.PatchSetApproval;
import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.reviewdb.server.ReviewDbUtil;
import com.google.gerrit.server.GerritPersonIdent;
import com.google.gerrit.server.PatchLineCommentsUtil;
import com.google.gerrit.server.account.AccountCache;
@@ -369,7 +370,7 @@ public class ChangeRebuilderImpl extends ChangeRebuilder {
return ComparisonChain.start()
.compareTrueFirst(a.predatesChange, b.predatesChange)
.compare(a.when, b.when)
.compare(a.who.get(), b.who.get())
.compare(a.who, b.who, ReviewDbUtil.intKeyOrdering())
.compare(a.psId.get(), b.psId.get())
.result();
}