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 dadef31f3e..1d83316f29 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 @@ -18,8 +18,6 @@ import static java.util.stream.Collectors.toList; import com.google.common.base.Strings; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; import com.google.gerrit.common.data.GroupReference; import com.google.gerrit.common.errors.NoSuchGroupException; import com.google.gerrit.extensions.common.GroupBaseInfo; @@ -275,10 +273,9 @@ public class ReviewersUtil { private List suggestAccountGroups( SuggestReviewers suggestReviewers, ProjectState projectState) { - return Lists.newArrayList( - Iterables.limit( - groupBackend.suggest(suggestReviewers.getQuery(), projectState), - suggestReviewers.getLimit())); + return groupBackend.suggest(suggestReviewers.getQuery(), projectState).stream() + .limit(suggestReviewers.getLimit()) + .collect(toList()); } private static class GroupAsReviewer { diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/group/ListGroups.java b/gerrit-server/src/main/java/com/google/gerrit/server/group/ListGroups.java index e94289481e..4b7fa6c474 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/group/ListGroups.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/group/ListGroups.java @@ -15,10 +15,10 @@ package com.google.gerrit.server.group; import static com.google.common.collect.ImmutableList.toImmutableList; +import static java.util.stream.Collectors.toList; import com.google.common.base.MoreObjects; import com.google.common.base.Strings; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Streams; import com.google.gerrit.common.data.GroupDescription; @@ -304,12 +304,12 @@ public class ListGroups implements RestReadView { "You should only have no more than one --project and -n with --suggest"); } List groupRefs = - Lists.newArrayList( - Iterables.limit( - groupBackend.suggest( - suggest, - projects.stream().findFirst().map(pc -> pc.getProjectState()).orElse(null)), - limit <= 0 ? 10 : Math.min(limit, 10))); + groupBackend + .suggest( + suggest, projects.stream().findFirst().map(pc -> pc.getProjectState()).orElse(null)) + .stream() + .limit(limit <= 0 ? 10 : Math.min(limit, 10)) + .collect(toList()); List groupInfos = Lists.newArrayListWithCapacity(groupRefs.size()); for (GroupReference ref : groupRefs) { diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/query/change/ChangeQueryBuilder.java b/gerrit-server/src/main/java/com/google/gerrit/server/query/change/ChangeQueryBuilder.java index 5aca6b4238..1edbc38dce 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/query/change/ChangeQueryBuilder.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/query/change/ChangeQueryBuilder.java @@ -21,8 +21,6 @@ import static java.util.stream.Collectors.toSet; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Enums; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.primitives.Ints; import com.google.gerrit.common.data.GroupDescription; @@ -1244,7 +1242,7 @@ public class ChangeQueryBuilder extends QueryBuilder { int maxTerms = args.indexConfig.maxTerms(); if (allMembers.size() > maxTerms) { // limit the number of query terms otherwise Gerrit will barf - accounts = ImmutableSet.copyOf(Iterables.limit(allMembers, maxTerms)); + accounts = allMembers.stream().limit(maxTerms).collect(toSet()); } else { accounts = allMembers; }