Merge "Use AccountCache#maybeGet instead of AccountCache#get when firing events"

This commit is contained in:
Edwin Kempin
2018-01-26 17:22:48 +00:00
committed by Gerrit Code Review
2 changed files with 7 additions and 2 deletions

View File

@@ -556,7 +556,7 @@ abstract class SubmitStrategyOp implements BatchUpdateOp {
args.changeMerged.fire(
updatedChange,
mergedPatchSet,
args.accountCache.get(submitter.getAccountId()),
args.accountCache.maybeGet(submitter.getAccountId()).orElse(null),
args.mergeTip.getCurrentTip().name(),
ctx.getWhen());
}

View File

@@ -23,6 +23,7 @@ import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Streams;
import com.google.gerrit.common.Nullable;
import com.google.gerrit.extensions.api.changes.NotifyHandling;
import com.google.gerrit.extensions.api.changes.RecipientType;
@@ -204,7 +205,11 @@ public class PostReviewersOp implements BatchUpdateOp {
accountsToNotify);
if (!addedReviewers.isEmpty()) {
List<AccountState> reviewers =
addedReviewers.stream().map(r -> accountCache.get(r.getAccountId())).collect(toList());
addedReviewers
.stream()
.map(r -> accountCache.maybeGet(r.getAccountId()))
.flatMap(Streams::stream)
.collect(toList());
reviewerAdded.fire(rsrc.getChange(), patchSet, reviewers, ctx.getAccount(), ctx.getWhen());
}
}