leventov commented on a change in pull request #6948: Add guava compatability
up to 27.0.1
URL: https://github.com/apache/incubator-druid/pull/6948#discussion_r303482915
##########
File path: core/src/main/java/org/apache/druid/common/guava/GuavaUtils.java
##########
@@ -19,16 +19,58 @@
package org.apache.druid.common.guava;
+import com.google.common.base.CharMatcher;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
+import com.google.common.net.HostAndPort;
import com.google.common.primitives.Longs;
+import org.apache.druid.java.util.common.IAE;
+import org.apache.druid.java.util.common.StringUtils;
import javax.annotation.Nullable;
+import javax.el.MethodNotFoundException;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Arrays;
/**
+ * This class contains a bunch of guava helper functions to bridge
compatability problems across guava versions, or
+ * between guava and java standard libraries. Any version compatability
related entries should have a reference to
+ * the critical commit(s).
*/
public class GuavaUtils
{
+ private static final CharMatcher BREAKING_WHITESPACE_INSTANCE;
+
+ static {
+ //
https://github.com/google/guava/commit/4fbb165ebf208d75100d5d47f56750d247f7d181
+ // Since v19.0
+ CharMatcher matcher;
+ try {
+ final Method m =
CharMatcher.class.getDeclaredMethod("breakingWhitespace");
+ matcher = (CharMatcher) m.invoke(null);
+ }
+ catch (IllegalAccessException | InvocationTargetException e) {
+ throw new IllegalStateException("Failed to fetch breakingWhitespace", e);
+ }
+ catch (NoSuchMethodException e) {
+ try {
+ final Field f =
CharMatcher.class.getDeclaredField("BREAKING_WHITESPACE");
+ matcher = (CharMatcher) f.get(null);
+ }
+ catch (IllegalAccessException e1) {
+ throw new IllegalStateException("Failed to access
BREAKING_WHITESPACE", e1);
+ }
+ catch (NoSuchFieldException e1) {
+ throw new IllegalStateException("Cannot find breaking white space in
guava", e1);
+ }
+ }
+ if (matcher == null) {
+ throw new IllegalStateException("wtf!?");
Review comment:
Please make the error message more constructive, or absent altogether
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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]