gharris1727 commented on code in PR #16604: URL: https://github.com/apache/kafka/pull/16604#discussion_r1700627317
########## connect/runtime/src/main/java/org/apache/kafka/connect/runtime/isolation/PluginUtils.java: ########## @@ -453,4 +457,56 @@ private static class DirectoryEntry { } } + private static Collection<URL> forJavaClassPath() { + Collection<URL> urls = new ArrayList<>(); + String javaClassPath = System.getProperty("java.class.path"); + if (javaClassPath != null) { + for (String path : javaClassPath.split(File.pathSeparator)) { + try { + urls.add(new File(path).toURI().toURL()); + } catch (Exception e) { + log.debug("Could not get URL", e); + } + } + } + return distinctUrls(urls); + } + + private static Collection<URL> forClassLoader(ClassLoader classLoader) { + final Collection<URL> result = new ArrayList<URL>(); + final ClassLoader[] loaders = classLoaders(classLoader); + for (ClassLoader loader : loaders) { + while (loader != null) { + if (loader instanceof URLClassLoader) { + URL[] urls = ((URLClassLoader) loader).getURLs(); + if (urls != null) { + result.addAll(new HashSet<URL>(Arrays.asList(urls))); + } + } + loader = loader.getParent(); + } + } + return distinctUrls(result); + } + + private static ClassLoader[] classLoaders(ClassLoader classLoader) { + if (classLoader == null) { Review Comment: I think this condition is wrong. And the condition probably shouldn't exist, because classLoader is never null. -- 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. To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org