gharris1727 commented on code in PR #13971: URL: https://github.com/apache/kafka/pull/13971#discussion_r1267082036
########## connect/runtime/src/main/java/org/apache/kafka/connect/runtime/isolation/PluginScanner.java: ########## @@ -118,35 +120,80 @@ private void loadJdbcDrivers(final ClassLoader loader) { } @SuppressWarnings({"rawtypes", "unchecked"}) - protected <T> PluginDesc<T> pluginDesc(Class<? extends T> plugin, String version, ClassLoader loader) { - return new PluginDesc(plugin, version, loader); + protected <T> PluginDesc<T> pluginDesc(Class<? extends T> plugin, String version, PluginSource source) { + return new PluginDesc(plugin, version, source.loader()); } @SuppressWarnings("unchecked") - protected <T> SortedSet<PluginDesc<T>> getServiceLoaderPluginDesc(Class<T> klass, ClassLoader loader) { + protected <T> SortedSet<PluginDesc<T>> getServiceLoaderPluginDesc(Class<T> klass, PluginSource source) { SortedSet<PluginDesc<T>> result = new TreeSet<>(); - ServiceLoader<T> serviceLoader = ServiceLoader.load(klass, loader); - for (Iterator<T> iterator = serviceLoader.iterator(); iterator.hasNext(); ) { - try (LoaderSwap loaderSwap = withClassLoader(loader)) { + ServiceLoader<T> serviceLoader = handleLinkageError(klass, source, () -> ServiceLoader.load(klass, source.loader())); Review Comment: In the case where an Implementation of ServiceLoader may eagerly-evaluate a first provider and cause a LinkageError to appear, I wanted to re-use the handleLinkageError logging. I don't think that the retries for these operations would be effective, and that the later retries would probably be wasteful. However, I thought re-using the same function in both places was simpler than customizing the behavior of each call. Since this code is (probably never) going to be exercised, I tried to keep it as simple as possible. Do you think that we should log errors from load and iterator? I can catch the error or just let it propagate to the caller. -- 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