ChangeData: Throw exception when failing to reload change

If a change cannot be reloaded from the database, instead of
returning null and letting subsequent call sites fail with
a null pointer exception, raise an exception with a message
that will help the administrator investigate.

An example of this is when a change was manually deleted from
the changes table, but references to it from other tables such
as patch_comments were not.

Bug: Issue 3871
Change-Id: I4dece22617d34a42eeb48bdce492124125fe9bc7
This commit is contained in:
David Pursehouse
2016-02-04 11:54:17 +09:00
parent dbb704462b
commit 7f31a6c050

View File

@@ -561,6 +561,9 @@ public class ChangeData {
public Change reloadChange() throws OrmException {
change = db.changes().get(legacyId);
if (change == null) {
throw new OrmException("Unable to load change " + legacyId);
}
return change;
}