gharris1727 commented on code in PR #13971:
URL: https://github.com/apache/kafka/pull/13971#discussion_r1267094589
##########
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()));
+ Iterator<T> iterator = handleLinkageError(klass, source,
serviceLoader::iterator);
+ while (handleLinkageError(klass, source, iterator::hasNext)) {
+ try (LoaderSwap loaderSwap = withClassLoader(source.loader())) {
T pluginImpl;
try {
- pluginImpl = iterator.next();
+ pluginImpl = handleLinkageError(klass, source,
iterator::next);
} catch (ServiceConfigurationError t) {
- log.error("Failed to discover {}{}",
klass.getSimpleName(), reflectiveErrorDescription(t.getCause()), t);
+ log.error("Failed to discover {} in {}{}",
+ klass.getSimpleName(), source.location(),
reflectiveErrorDescription(t.getCause()), t);
Review Comment:
> Since that field (and its accessor method) are currently only used for log
messages, what do you think about altering PluginSource::location to return a
string, and using "System classpath" in that case?
I can't do that, because I need the Path object later in the migration
script. I've used a non-null sentinel path instead, so that all of the logging
call-sites are improved but the Path object is still available.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]