Source:
protected ClassLoader buildClassLoader(final TaskToolbox toolbox) throws Exception { final List<String> finalHadoopDependencyCoordinates = hadoopDependencyCoordinates != null ? hadoopDependencyCoordinates : toolbox.getConfig().getDefaultHadoopCoordinates(); final List<URL> extensionURLs = Lists.newArrayList(); for (final File extension : Initialization.getExtensionFilesToLoad(extensionsConfig)) { final ClassLoader extensionLoader = Initialization.getClassLoaderForExtension(extension); extensionURLs.addAll(Arrays.asList(((URLClassLoader) extensionLoader).getURLs())); } final List<URL> nonHadoopURLs = Lists.newArrayList(); nonHadoopURLs.addAll(Arrays.asList(((URLClassLoader) HadoopIndexTask.class.getClassLoader()).getURLs())); final List<URL> druidURLs = ImmutableList.copyOf( Collections2.filter(nonHadoopURLs, IS_DRUID_URL) ); final List<URL> nonDruidURLs = Lists.newArrayList(nonHadoopURLs); nonDruidURLs.removeAll(druidURLs); ClassLoader classLoader = null; classLoader = new URLClassLoader(nonDruidURLs.toArray(new URL[nonDruidURLs.size()]), classLoader); for (final File hadoopDependency : Initialization.getHadoopDependencyFilesToLoad( finalHadoopDependencyCoordinates, extensionsConfig )) { final ClassLoader hadoopLoader = Initialization.getClassLoaderForExtension(hadoopDependency); classLoader = new URLClassLoader(((URLClassLoader) hadoopLoader).getURLs(), classLoader); } classLoader = new URLClassLoader(druidURLs.toArray(new URL[druidURLs.size()]), classLoader); classLoader = new URLClassLoader(extensionURLs.toArray(new URL[extensionURLs.size()]), classLoader); final List<URL> jobUrls = Lists.newArrayList(); jobUrls.addAll(nonHadoopURLs); jobUrls.addAll(extensionURLs); System.setProperty("druid.hadoop.internal.classpath", Joiner.on(File.pathSeparator).join(jobUrls)); return classLoader; }

Target:
protected ClassLoader buildClassLoader(final TaskToolbox toolbox) throws Exception { final List<String> finalHadoopDependencyCoordinates = hadoopDependencyCoordinates != null ? hadoopDependencyCoordinates : toolbox.getConfig().getDefaultHadoopCoordinates(); final List<URL> extensionURLs = Lists.newArrayList(); for (final File extension : Initialization.getExtensionFilesToLoad(extensionsConfig)) { final ClassLoader extensionLoader = Initialization.getClassLoaderForExtension(extension); extensionURLs.addAll(Arrays.asList(((URLClassLoader) extensionLoader).getURLs())); } final List<URL> nonHadoopURLs = Lists.newArrayList(); nonHadoopURLs.addAll(Arrays.asList(((URLClassLoader) HadoopIndexTask.class.getClassLoader()).getURLs())); final List<URL> druidURLs = ImmutableList.copyOf( Collections2.filter(nonHadoopURLs, IS_DRUID_URL) ); final List<URL> nonHadoopNotDruidURLs = Lists.newArrayList(nonHadoopURLs); nonHadoopNotDruidURLs.removeAll(druidURLs); ClassLoader classLoader = null; classLoader = new URLClassLoader(nonHadoopNotDruidURLs.toArray(new URL[nonHadoopNotDruidURLs.size()]), classLoader); for (final File hadoopDependency : Initialization.getHadoopDependencyFilesToLoad( finalHadoopDependencyCoordinates, extensionsConfig )) { final ClassLoader hadoopLoader = Initialization.getClassLoaderForExtension(hadoopDependency); classLoader = new URLClassLoader(((URLClassLoader) hadoopLoader).getURLs(), classLoader); } classLoader = new URLClassLoader(druidURLs.toArray(new URL[druidURLs.size()]), classLoader); classLoader = new URLClassLoader(extensionURLs.toArray(new URL[extensionURLs.size()]), classLoader); final List<URL> jobUrls = Lists.newArrayList(); jobUrls.addAll(nonHadoopURLs); jobUrls.addAll(extensionURLs); System.setProperty("druid.hadoop.internal.classpath", Joiner.on(File.pathSeparator).join(jobUrls)); return classLoader; }