ValidatorConfig: Avoid 'stream::iterator'

The method reference stream::iterator is considered unsafe as it's
mapped to the Iterable interface which can be iterated multiple times
whereas a stream may only be iterated once.

I268068f84 did a similar cleanup in core Gerrit. This change improves
the only usage of stream::iterator in the uploadvalidator plugin.

In the specific case of ValidatorConfig, we can safely switch to a
manifestation of an ImmutableList as ValidatorConfig#groupUUID returns
only non-null values and conf.getStringList("skipGroup") already
reads/manifests all values. Hence, there shouldn't be any negative
side-effects when switching to an ImmutableList here.

Change-Id: Ib81ef3b5e0e6e254d4e3189de49abfa37415771d
diff --git a/src/main/java/com/googlesource/gerrit/plugins/uploadvalidator/ValidatorConfig.java b/src/main/java/com/googlesource/gerrit/plugins/uploadvalidator/ValidatorConfig.java
index 4aae4d6..aea74a6 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/uploadvalidator/ValidatorConfig.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/uploadvalidator/ValidatorConfig.java
@@ -14,9 +14,13 @@
 
 package com.googlesource.gerrit.plugins.uploadvalidator;
 
+import static com.google.common.collect.ImmutableList.toImmutableList;
+
+import com.google.common.collect.ImmutableList;
 import com.google.gerrit.common.Nullable;
 import com.google.gerrit.entities.AccessSection;
 import com.google.gerrit.entities.AccountGroup;
+import com.google.gerrit.entities.AccountGroup.UUID;
 import com.google.gerrit.entities.Project;
 import com.google.gerrit.exceptions.StorageException;
 import com.google.gerrit.extensions.annotations.Exports;
@@ -33,7 +37,6 @@
 import java.util.Arrays;
 import java.util.Optional;
 import java.util.regex.Pattern;
-import java.util.stream.Stream;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -170,9 +173,11 @@
       return false;
     }
 
-    Stream<AccountGroup.UUID> skipGroups =
-        Arrays.stream(conf.getStringList("skipGroup")).map(this::groupUUID);
-    return user.asIdentifiedUser().getEffectiveGroups().containsAnyOf(skipGroups::iterator);
+    ImmutableList<UUID> skipGroups =
+        Arrays.stream(conf.getStringList("skipGroup"))
+            .map(this::groupUUID)
+            .collect(toImmutableList());
+    return user.asIdentifiedUser().getEffectiveGroups().containsAnyOf(skipGroups);
   }
 
   private AccountGroup.UUID groupUUID(String groupNameOrUUID) {