summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--java/com/google/gerrit/server/mail/send/OutgoingEmail.java12
1 files changed, 10 insertions, 2 deletions
diff --git a/java/com/google/gerrit/server/mail/send/OutgoingEmail.java b/java/com/google/gerrit/server/mail/send/OutgoingEmail.java
index 664c1bf8a5..5b131692fb 100644
--- a/java/com/google/gerrit/server/mail/send/OutgoingEmail.java
+++ b/java/com/google/gerrit/server/mail/send/OutgoingEmail.java
@@ -22,6 +22,7 @@ import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Sets;
import com.google.common.flogger.FluentLogger;
+import com.google.gerrit.common.Nullable;
import com.google.gerrit.common.errors.EmailException;
import com.google.gerrit.extensions.api.changes.NotifyHandling;
import com.google.gerrit.extensions.api.changes.RecipientType;
@@ -340,7 +341,7 @@ public abstract class OutgoingEmail {
}
/** Lookup a human readable name for an account, usually the "full name". */
- protected String getNameFor(Account.Id accountId) {
+ protected String getNameFor(@Nullable Account.Id accountId) {
if (accountId == null) {
return args.gerritPersonIdent.getName();
}
@@ -366,7 +367,14 @@ public abstract class OutgoingEmail {
* @param accountId user to fetch.
* @return name/email of account, or Anonymous Coward if unset.
*/
- protected String getNameEmailFor(Account.Id accountId) {
+ protected String getNameEmailFor(@Nullable Account.Id accountId) {
+ if (accountId == null) {
+ return args.gerritPersonIdent.getName()
+ + " <"
+ + args.gerritPersonIdent.getEmailAddress()
+ + ">";
+ }
+
Optional<Account> account = args.accountCache.get(accountId).map(AccountState::getAccount);
if (account.isPresent()) {
String name = account.get().getFullName();