From 08de4a4ab14528081eaf2f818a394da3cdc011e9 Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Mon, 14 Sep 2015 13:26:04 -0400 Subject: [PATCH] Remove use of com.google.common.collect.Iterables This commit removes all uses of com.google.common.collect.Iterables across the codebase. Relates elastic/elasticsearchelastic/elasticsearch#13224 Original commit: elastic/x-pack-elasticsearch@ca517de4121c39effb0a9f22e8f34cb56c508f76 --- .../shield/authc/ldap/support/SessionFactory.java | 5 ++--- .../watcher/execution/AsyncTriggerListener.java | 5 +++-- .../elasticsearch/watcher/execution/SyncTriggerListener.java | 5 +++-- .../watcher/support/text/xmustache/XMustacheFactory.java | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/shield/src/main/java/org/elasticsearch/shield/authc/ldap/support/SessionFactory.java b/shield/src/main/java/org/elasticsearch/shield/authc/ldap/support/SessionFactory.java index fa34ed7ab2d..f575cb444cc 100644 --- a/shield/src/main/java/org/elasticsearch/shield/authc/ldap/support/SessionFactory.java +++ b/shield/src/main/java/org/elasticsearch/shield/authc/ldap/support/SessionFactory.java @@ -19,7 +19,6 @@ import org.elasticsearch.shield.authc.support.SecuredString; import java.util.regex.Pattern; -import static com.google.common.collect.Iterables.all; import static java.util.Arrays.asList; /** @@ -147,8 +146,8 @@ public abstract class SessionFactory { return true; } - boolean allSecure = all(asList(ldapUrls), s -> STARTS_WITH_LDAPS.matcher(s).find()); - boolean allClear = all(asList(ldapUrls), s -> STARTS_WITH_LDAP.matcher(s).find()); + boolean allSecure = asList(ldapUrls).stream().allMatch(s -> STARTS_WITH_LDAPS.matcher(s).find()); + boolean allClear = asList(ldapUrls).stream().allMatch(s -> STARTS_WITH_LDAP.matcher(s).find()); if (!allSecure && !allClear) { //No mixing is allowed because we use the same socketfactory diff --git a/watcher/src/main/java/org/elasticsearch/watcher/execution/AsyncTriggerListener.java b/watcher/src/main/java/org/elasticsearch/watcher/execution/AsyncTriggerListener.java index 6999f6312e3..2c988cc2a15 100644 --- a/watcher/src/main/java/org/elasticsearch/watcher/execution/AsyncTriggerListener.java +++ b/watcher/src/main/java/org/elasticsearch/watcher/execution/AsyncTriggerListener.java @@ -5,7 +5,6 @@ */ package org.elasticsearch.watcher.execution; -import com.google.common.collect.Iterables; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; @@ -14,6 +13,8 @@ import org.elasticsearch.watcher.trigger.TriggerEngine; import org.elasticsearch.watcher.trigger.TriggerEvent; import org.elasticsearch.watcher.trigger.TriggerService; +import java.util.stream.StreamSupport; + /** */ public class AsyncTriggerListener implements TriggerEngine.Listener { @@ -33,7 +34,7 @@ public class AsyncTriggerListener implements TriggerEngine.Listener { try { executionService.processEventsAsync(events); } catch (Exception e) { - logger.error("failed to process triggered events [{}]", e, (Object)Iterables.toArray(events, TriggerEvent.class)); + logger.error("failed to process triggered events [{}]", e, (Object) StreamSupport.stream(events.spliterator(), false).toArray(size -> new TriggerEvent[size])); } } diff --git a/watcher/src/main/java/org/elasticsearch/watcher/execution/SyncTriggerListener.java b/watcher/src/main/java/org/elasticsearch/watcher/execution/SyncTriggerListener.java index aa2e5563503..8c97d42104e 100644 --- a/watcher/src/main/java/org/elasticsearch/watcher/execution/SyncTriggerListener.java +++ b/watcher/src/main/java/org/elasticsearch/watcher/execution/SyncTriggerListener.java @@ -5,7 +5,6 @@ */ package org.elasticsearch.watcher.execution; -import com.google.common.collect.Iterables; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; @@ -14,6 +13,8 @@ import org.elasticsearch.watcher.trigger.TriggerEngine; import org.elasticsearch.watcher.trigger.TriggerEvent; import org.elasticsearch.watcher.trigger.TriggerService; +import java.util.stream.StreamSupport; + /** */ public class SyncTriggerListener implements TriggerEngine.Listener { @@ -33,7 +34,7 @@ public class SyncTriggerListener implements TriggerEngine.Listener { try { executionService.processEventsSync(events); } catch (Exception e) { - logger.error("failed to process triggered events [{}]", e, (Object)Iterables.toArray(events, TriggerEvent.class)); + logger.error("failed to process triggered events [{}]", e, (Object) StreamSupport.stream(events.spliterator(), false).toArray(size -> new TriggerEvent[size])); } } diff --git a/watcher/src/main/java/org/elasticsearch/watcher/support/text/xmustache/XMustacheFactory.java b/watcher/src/main/java/org/elasticsearch/watcher/support/text/xmustache/XMustacheFactory.java index 2d7e09e025d..33d34d9b807 100644 --- a/watcher/src/main/java/org/elasticsearch/watcher/support/text/xmustache/XMustacheFactory.java +++ b/watcher/src/main/java/org/elasticsearch/watcher/support/text/xmustache/XMustacheFactory.java @@ -9,7 +9,7 @@ import com.fasterxml.jackson.core.io.JsonStringEncoder; import com.github.mustachejava.DefaultMustacheFactory; import com.github.mustachejava.MustacheException; import com.github.mustachejava.reflect.ReflectionObjectHandler; -import com.google.common.collect.Iterables; +import org.elasticsearch.common.util.iterable.Iterables; import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.watcher.support.ArrayObjectIterator;