NoteDbChangeState: Protect against zeroIds for draft SHA-1s.

We found a few of these in the wild on gerrit-review. Still not sure
how they cropped up, but they're confusing DraftCommentNotes, so
filter them out.

Change-Id: I922730b2a79802e8fa1908eb186660929a452e69
This commit is contained in:
Dave Borowitz
2016-06-02 13:03:27 -04:00
parent af23970959
commit b6c4880383

View File

@@ -22,6 +22,7 @@ import static com.google.gerrit.reviewdb.client.RefNames.refsDraftComments;
import com.google.auto.value.AutoValue;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Optional;
import com.google.common.base.Predicates;
import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
@@ -181,7 +182,8 @@ public class NoteDbChangeState {
Map<Account.Id, ObjectId> draftIds) {
this.changeId = checkNotNull(changeId);
this.changeMetaId = checkNotNull(changeMetaId);
this.draftIds = ImmutableMap.copyOf(draftIds);
this.draftIds = ImmutableMap.copyOf(Maps.filterValues(
draftIds, Predicates.not(Predicates.equalTo(ObjectId.zeroId()))));
}
public boolean isChangeUpToDate(RefCache changeRepoRefs) throws IOException {