Files
gerrit/java
Edwin Kempin 32cf19ad46 OutgoingEmail: Handle null accountId in getNameEmailFor(Account.Id) method
If an email should be sent and a current user is not available (e.g.
because the operation is executed in the background) we cannot set an
account ID as the sender of the email. In this case we skip calling
OutgoingEmail#setFrom(Account.Id) and the fromId stays null (e.g. see
AbandonOp which can be executed in the background). If the fromId is
null and we setup the soy context (ChangeEmail#setupSoyContext()) we get
a NullPointerException when trying to set the fromEmail field. This is
because getNameEmailFor(Account.Id) doesn't expect null as value. In
contrast to this method, the getNameFor(Account.Id) method which is
called before to set the fromName field does handle null as value by
falling back to the Gerrit person ident. Fix the NullPointerException in
getNameEmailFor(Account.Id) by doing the same, and make it also fall
back to the Gerrit person ident if the given account ID is null.

Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: I63d50f4407b4f95eaaf73e41c5a1288ed4a16eb4
2019-09-30 10:01:47 +02:00
..