Only send mail to author and committer if they are registered

Only send an e-mail notification to the change author / committer if
the author / committer is a registered user in Gerrit. Gerrit users
that have the Forge Author / Forge Committer access right are able to
push changes that have an author / committer that is not registered
in Gerrit.

The current code may run into an NPE when there is a change with a
non-registered author / committer, because for such a user the
Account.Id is null which is not handled (e.g. an NPE occurs when
pushing a change with an non-registered author / committer to
refs/draft/).

Change-Id: Id32839d93bd0aff35e25557ffbea9157a63a7b09
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
Edwin Kempin
2012-02-07 12:50:11 +01:00
parent 388ba60191
commit 0a24796a21

View File

@@ -417,8 +417,12 @@ public abstract class ChangeEmail extends OutgoingEmail {
authors.add(patchSet.getUploader());
}
if (patchSetInfo != null) {
authors.add(patchSetInfo.getAuthor().getAccount());
authors.add(patchSetInfo.getCommitter().getAccount());
if (patchSetInfo.getAuthor().getAccount() != null) {
authors.add(patchSetInfo.getAuthor().getAccount());
}
if (patchSetInfo.getCommitter().getAccount() != null) {
authors.add(patchSetInfo.getCommitter().getAccount());
}
}
return authors;
}