EventFactory: Remove redundant null-check of notes

The check for null notes was being done after notes had already
been dereferenced earlier. If it was null, NPE would already have
been raised.

Remove the redundant check and add a call to checkNotNull earlier.

Change-Id: I8eb39de4e6cfd32e6c1bf790e916a89b9c0c8593
This commit is contained in:
David Pursehouse
2016-02-12 10:56:43 +09:00
parent 03fe01c936
commit 20e0d3ee26

View File

@@ -384,6 +384,7 @@ public class EventFactory {
Map<PatchSet.Id, Collection<PatchSetApproval>> approvals,
boolean includeFiles, ChangeNotes notes, LabelTypes labelTypes) {
if (!ps.isEmpty()) {
checkNotNull(notes, "notes may not be null");
ca.patchSets = new ArrayList<>(ps.size());
for (PatchSet p : ps) {
PatchSetAttribute psa = asPatchSetAttribute(db, revWalk, notes, p);
@@ -391,7 +392,7 @@ public class EventFactory {
addApprovals(psa, p.getId(), approvals, labelTypes);
}
ca.patchSets.add(psa);
if (includeFiles && notes != null) {
if (includeFiles) {
addPatchSetFileNames(psa, notes.getChange(), p);
}
}