PARADOXST commented on code in PR #16604: URL: https://github.com/apache/kafka/pull/16604#discussion_r1711681006
########## connect/runtime/src/main/java/org/apache/kafka/connect/runtime/isolation/PluginUtils.java: ########## @@ -453,4 +455,40 @@ 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>(); + while (classLoader != null) { + if (classLoader instanceof URLClassLoader) { + URL[] urls = ((URLClassLoader) classLoader).getURLs(); + if (urls != null) { + result.addAll(new HashSet<URL>(Arrays.asList(urls))); + } + } + classLoader = classLoader.getParent(); + } + return distinctUrls(result); + } + + private static Collection<URL> distinctUrls(Collection<URL> urls) { + Map<String, URL> distinct = new HashMap<String, URL>(urls.size()); Review Comment: Done. ########## connect/runtime/src/main/java/org/apache/kafka/connect/runtime/isolation/PluginUtils.java: ########## @@ -453,4 +455,40 @@ 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>(); + while (classLoader != null) { + if (classLoader instanceof URLClassLoader) { + URL[] urls = ((URLClassLoader) classLoader).getURLs(); + if (urls != null) { + result.addAll(new HashSet<URL>(Arrays.asList(urls))); Review Comment: Done. ########## connect/runtime/src/main/java/org/apache/kafka/connect/runtime/isolation/PluginUtils.java: ########## @@ -453,4 +455,40 @@ 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>(); Review Comment: Done. -- 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