QiuMM closed pull request #6800: Copy splitToList from Guava
URL: https://github.com/apache/incubator-druid/pull/6800
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/NOTICE b/NOTICE
index 8207daca8c9..fb92a6d37dd 100644
--- a/NOTICE
+++ b/NOTICE
@@ -77,7 +77,7 @@ This product contains a modified version of The Guava 
Authors's Closer class fro
  * HOMEPAGE:
    * https://github.com/google/guava
  * COMMIT TAG:
-   * 
https://github.com/google/guava/blob/c462d69329709f72a17a64cb229d15e76e72199c
+   * 
https://github.com/google/guava/commit/0ba7ccf36f5384a321cb78d62375bf7574e7bc24
 
 This product contains code adapted from Apache Hadoop
   * LICENSE:
diff --git 
a/core/src/main/java/org/apache/druid/java/util/common/parsers/DelimitedParser.java
 
b/core/src/main/java/org/apache/druid/java/util/common/parsers/DelimitedParser.java
index 0953fdc2753..61eafa70f19 100644
--- 
a/core/src/main/java/org/apache/druid/java/util/common/parsers/DelimitedParser.java
+++ 
b/core/src/main/java/org/apache/druid/java/util/common/parsers/DelimitedParser.java
@@ -24,6 +24,9 @@
 import com.google.common.base.Splitter;
 
 import javax.annotation.Nullable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
 import java.util.List;
 
 public class DelimitedParser extends AbstractFlatTextFormatParser
@@ -74,6 +77,26 @@ public DelimitedParser(
   @Override
   protected List<String> parseLine(String input)
   {
-    return splitter.splitToList(input);
+    return splitToList(input);
+  }
+
+  /**
+   * Copied from Guava's {@link Splitter#splitToList(CharSequence)}.
+   * This is to avoid the error of the missing method signature when using an 
old Guava library.
+   * For example, it may happen when running Druid Hadoop indexing jobs, since 
we may inherit the version provided by
+   * the Hadoop cluster. See 
https://github.com/apache/incubator-druid/issues/6801.
+   */
+  private List<String> splitToList(String input)
+  {
+    Preconditions.checkNotNull(input);
+
+    Iterator<String> iterator = splitter.split(input).iterator();
+    List<String> result = new ArrayList<String>();
+
+    while (iterator.hasNext()) {
+      result.add(iterator.next());
+    }
+
+    return Collections.unmodifiableList(result);
   }
 }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to