diff options
author | David Pursehouse <dpursehouse@collab.net> | 2019-11-05 10:41:01 +0900 |
---|---|---|
committer | David Pursehouse <dpursehouse@collab.net> | 2019-11-06 08:55:05 +0900 |
commit | 75efa611fbc927d74b15ca4950c02d49fb72c86f (patch) | |
tree | dde457a6ad10d7f24ed93c1d1d1b7f43db1abfdd | |
parent | 93a2133d4bf90a7ef5655543ad8f9816c7ceae31 (diff) |
ReviewerUtil: Keep only AccountLoader.Factory
Instead of instantiating the account loader in the constructor, keep
the factory and instantiate the loader as it's needed. Also keep the
fill options as a member initialized in the constructor rather than
instantiating the same enum set every time.
Change-Id: I50ad806a137623e25d49198538a675645c1dbce4
-rw-r--r-- | gerrit-server/src/main/java/com/google/gerrit/server/ReviewersUtil.java | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/ReviewersUtil.java b/gerrit-server/src/main/java/com/google/gerrit/server/ReviewersUtil.java index 1d83316f29..d210f5afc3 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/ReviewersUtil.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/ReviewersUtil.java @@ -105,7 +105,7 @@ public class ReviewersUtil { // give the ranking algorithm a good set of candidates it can work with private static final int CANDIDATE_LIST_MULTIPLIER = 2; - private final AccountLoader accountLoader; + private final AccountLoader.Factory accountLoaderFactory; private final AccountQueryBuilder accountQueryBuilder; private final Provider<AccountQueryProcessor> queryProvider; private final GroupBackend groupBackend; @@ -113,6 +113,7 @@ public class ReviewersUtil { private final Provider<CurrentUser> currentUser; private final ReviewerRecommender reviewerRecommender; private final Metrics metrics; + private final EnumSet<FillOptions> fillOptions; @Inject ReviewersUtil( @@ -124,9 +125,9 @@ public class ReviewersUtil { Provider<CurrentUser> currentUser, ReviewerRecommender reviewerRecommender, Metrics metrics) { - Set<FillOptions> fillOptions = EnumSet.of(FillOptions.SECONDARY_EMAILS); - fillOptions.addAll(AccountLoader.DETAILED_OPTIONS); - this.accountLoader = accountLoaderFactory.create(fillOptions); + this.fillOptions = EnumSet.of(FillOptions.SECONDARY_EMAILS); + this.fillOptions.addAll(AccountLoader.DETAILED_OPTIONS); + this.accountLoaderFactory = accountLoaderFactory; this.accountQueryBuilder = accountQueryBuilder; this.queryProvider = queryProvider; this.currentUser = currentUser; @@ -222,6 +223,7 @@ public class ReviewersUtil { private List<SuggestedReviewerInfo> loadAccounts(List<Account.Id> accountIds) throws OrmException { try (Timer0.Context ctx = metrics.loadAccountsLatency.start()) { + AccountLoader accountLoader = accountLoaderFactory.create(fillOptions); List<SuggestedReviewerInfo> reviewer = accountIds.stream() .map(accountLoader::get) |