Fix CheckIT#currentPatchSetMissing() test when notedb is enabled

The test intentionally creates a change with a missing patch set, this
was causing a NullPointerException in the notedb code path when the
inconsistent change was indexed and the approvals for the missing
patch set were requested. Do not fail when approvals for a
non-existing patch set are requested but just return an empty list of
approvals.

Change-Id: Ia4c23eef287ef8f0936598a14607a402d9575f50
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2015-10-27 17:28:48 +01:00
parent 5d393880e2
commit d1ccd29f0b

View File

@@ -46,6 +46,7 @@ import org.eclipse.jgit.lib.Repository;
import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.NavigableSet;
import java.util.Objects;
@@ -87,7 +88,11 @@ public class ApprovalCopier {
Iterable<PatchSetApproval> getForPatchSet(ReviewDb db,
ChangeControl ctl, PatchSet.Id psId) throws OrmException {
return getForPatchSet(db, ctl, db.patchSets().get(psId));
PatchSet ps = db.patchSets().get(psId);
if (ps == null) {
return Collections.emptyList();
}
return getForPatchSet(db, ctl, ps);
}
private Iterable<PatchSetApproval> getForPatchSet(ReviewDb db,