diff --git a/indexing-service/src/main/java/io/druid/indexing/common/task/HadoopTask.java b/indexing-service/src/main/java/io/druid/indexing/common/task/HadoopTask.java index d68355c4681..cb1fc7e3204 100644 --- a/indexing-service/src/main/java/io/druid/indexing/common/task/HadoopTask.java +++ b/indexing-service/src/main/java/io/druid/indexing/common/task/HadoopTask.java @@ -22,7 +22,6 @@ package io.druid.indexing.common.task; import com.google.common.base.Joiner; import com.google.common.base.Predicate; import com.google.common.base.Throwables; -import com.google.common.collect.Collections2; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.inject.Injector; @@ -132,23 +131,16 @@ public abstract class HadoopTask extends AbstractTask ? hadoopDependencyCoordinates : toolbox.getConfig().getDefaultHadoopCoordinates(); - final List extensionURLs = Lists.newArrayList(); + final List jobURLs = Lists.newArrayList( + Arrays.asList(((URLClassLoader) HadoopIndexTask.class.getClassLoader()).getURLs()) + ); + for (final File extension : Initialization.getExtensionFilesToLoad(extensionsConfig)) { final ClassLoader extensionLoader = Initialization.getClassLoaderForExtension(extension); - extensionURLs.addAll(Arrays.asList(((URLClassLoader) extensionLoader).getURLs())); + jobURLs.addAll(Arrays.asList(((URLClassLoader) extensionLoader).getURLs())); } - final List nonHadoopURLs = Lists.newArrayList(); - nonHadoopURLs.addAll(Arrays.asList(((URLClassLoader) HadoopIndexTask.class.getClassLoader()).getURLs())); - - final List druidURLs = ImmutableList.copyOf( - Collections2.filter(nonHadoopURLs, IS_DRUID_URL) - ); - final List nonHadoopNotDruidURLs = Lists.newArrayList(nonHadoopURLs); - nonHadoopNotDruidURLs.removeAll(druidURLs); - - final List localClassLoaderURLs = new ArrayList<>(); - localClassLoaderURLs.addAll(nonHadoopNotDruidURLs); + final List localClassLoaderURLs = new ArrayList<>(jobURLs); // hadoop dependencies come before druid classes because some extensions depend on them for (final File hadoopDependency : @@ -160,15 +152,12 @@ public abstract class HadoopTask extends AbstractTask localClassLoaderURLs.addAll(Arrays.asList(((URLClassLoader) hadoopLoader).getURLs())); } - localClassLoaderURLs.addAll(druidURLs); - localClassLoaderURLs.addAll(extensionURLs); - final ClassLoader classLoader = new URLClassLoader(localClassLoaderURLs.toArray(new URL[localClassLoaderURLs.size()]), null); + final ClassLoader classLoader = new URLClassLoader( + localClassLoaderURLs.toArray(new URL[localClassLoaderURLs.size()]), + null + ); - final List jobUrls = Lists.newArrayList(); - jobUrls.addAll(nonHadoopURLs); - jobUrls.addAll(extensionURLs); - - System.setProperty("druid.hadoop.internal.classpath", Joiner.on(File.pathSeparator).join(jobUrls)); + System.setProperty("druid.hadoop.internal.classpath", Joiner.on(File.pathSeparator).join(jobURLs)); return classLoader; }