Merge branch 'stable-2.14'

* stable-2.14:
  Avoid NullPointerException when calling ChangeNotes

Change-Id: Ia78ece2c6828a7b9d1bf964c8714ce20be079da9
This commit is contained in:
David Pursehouse
2017-09-30 16:02:43 +01:00

View File

@@ -167,22 +167,18 @@ public class ChangeNotes extends AbstractChangeNotes<ChangeNotes> {
checkArgument(project != null, "project is required"); checkArgument(project != null, "project is required");
Change change = readOneReviewDbChange(db, changeId); Change change = readOneReviewDbChange(db, changeId);
if (change == null && args.migration.readChanges()) { if (change == null) {
// Change isn't in ReviewDb, but its primary storage might be in NoteDb. if (args.migration.readChanges()) {
// Prepopulate the change exists with proper noteDbState field. return newNoteDbOnlyChange(project, changeId);
change = newNoteDbOnlyChange(project, changeId); }
} else { throw new NoSuchChangeException(changeId);
checkNotNull(change, "change %s not found in ReviewDb", changeId); }
checkArgument( checkArgument(
change.getProject().equals(project), change.getProject().equals(project),
"passed project %s when creating ChangeNotes for %s, but actual project is %s", "passed project %s when creating ChangeNotes for %s, but actual project is %s",
project, project,
changeId, changeId,
change.getProject()); change.getProject());
}
// TODO: Throw NoSuchChangeException when the change is not found in the
// database
return change; return change;
} }