You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by xv...@apache.org on 2019/08/25 03:47:25 UTC
[incubator-druid] 01/01: workaround for Guava 16 bug using Java 9
and above
This is an automated email from the ASF dual-hosted git repository.
xvrl pushed a commit to branch jdk11-workaround-guava-bug
in repository https://gitbox.apache.org/repos/asf/incubator-druid.git
commit c3b088f103bb4f2ea0266208e5aebf40cba1e4bf
Author: Xavier Léauté <xv...@apache.org>
AuthorDate: Sat Aug 24 21:59:14 2019 -0400
workaround for Guava 16 bug using Java 9 and above
---
.../src/test/java/org/apache/druid/guice/FirehoseModuleTest.java | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/server/src/test/java/org/apache/druid/guice/FirehoseModuleTest.java b/server/src/test/java/org/apache/druid/guice/FirehoseModuleTest.java
index c6fec21..e4f0340 100644
--- a/server/src/test/java/org/apache/druid/guice/FirehoseModuleTest.java
+++ b/server/src/test/java/org/apache/druid/guice/FirehoseModuleTest.java
@@ -28,11 +28,14 @@ import com.fasterxml.jackson.databind.jsontype.NamedType;
import com.google.common.reflect.ClassPath;
import org.apache.druid.data.input.FirehoseFactory;
import org.apache.druid.segment.realtime.firehose.ClippedFirehoseFactory;
+import org.apache.druid.utils.JvmUtils;
import org.junit.Assert;
import org.junit.Test;
import java.io.IOException;
import java.lang.reflect.Modifier;
+import java.net.URL;
+import java.net.URLClassLoader;
import java.util.Collection;
import java.util.Set;
import java.util.function.Predicate;
@@ -79,8 +82,10 @@ public class FirehoseModuleTest
@SuppressWarnings("UnstableApiUsage") // for ClassPath
private static Set<Class> getFirehoseFactoryClassesInPackage(String packageName) throws IOException
{
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- ClassPath classPath = ClassPath.from(loader);
+ // workaround for Guava 16, which can only parse the classpath from URLClassLoaders
+ // requires Guava 28 or later to work properly with the system class loader in Java 9 and above
+ URLClassLoader classloader = new URLClassLoader(JvmUtils.systemClassPath().toArray(new URL[0]));
+ ClassPath classPath = ClassPath.from(classloader);
return classPath.getTopLevelClasses(packageName).stream()
.map(ClassPath.ClassInfo::load)
.filter(IS_FIREHOSE_FACTORY)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org