ListMembers: Keep only AccountLoader.Factory in REST handler
It's cleaner to keep only factories in REST API handlers - even when
the class is not a Singleton. This way, copy-and-paste errors are
reduced to a minimum.
Change-Id: Ieae81dbc92b9546bbe12af29f3040362e5eb5f96
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/group/ListMembers.java b/gerrit-server/src/main/java/com/google/gerrit/server/group/ListMembers.java
index af988b8..8682097 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/group/ListMembers.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/group/ListMembers.java
@@ -40,7 +40,7 @@
public class ListMembers implements RestReadView<GroupResource> {
private final GroupCache groupCache;
private final GroupControl.Factory groupControlFactory;
- private final AccountLoader accountLoader;
+ private final AccountLoader.Factory accountLoaderFactory;
@Option(name = "--recursive", usage = "to resolve included groups recursively")
private boolean recursive;
@@ -52,7 +52,7 @@
AccountLoader.Factory accountLoaderFactory) {
this.groupCache = groupCache;
this.groupControlFactory = groupControlFactory;
- this.accountLoader = accountLoaderFactory.create(true);
+ this.accountLoaderFactory = accountLoaderFactory;
}
public ListMembers setRecursive(boolean recursive) {
@@ -71,6 +71,7 @@
public List<AccountInfo> apply(AccountGroup.UUID groupId) throws OrmException {
Set<Account.Id> members = getMembers(groupId, new HashSet<>());
List<AccountInfo> memberInfos = new ArrayList<>(members.size());
+ AccountLoader accountLoader = accountLoaderFactory.create(true);
for (Account.Id member : members) {
memberInfos.add(accountLoader.get(member));
}