gharris1727 commented on code in PR #18403:
URL: https://github.com/apache/kafka/pull/18403#discussion_r1909243168


##########
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/isolation/ReflectionScanner.java:
##########
@@ -77,7 +79,8 @@ private static <T> String versionFor(Class<? extends T> 
pluginKlass) throws Refl
     @Override
     protected PluginScanResult scanPlugins(PluginSource source) {
         ClassGraph classGraphBuilder = new ClassGraph()
-                .addClassLoader(source.loader())
+            .addClassLoader(source.loader())

Review Comment:
   nit: this is a no-op now and can be removed



##########
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/isolation/ReflectionScanner.java:
##########
@@ -105,6 +108,23 @@ private SortedSet<PluginDesc<Transformation<?>>> 
getTransformationPluginDesc(Plu
         return (SortedSet<PluginDesc<Transformation<?>>>) (SortedSet<?>) 
getPluginDesc(classGraph, PluginType.TRANSFORMATION, source);
     }
 
+    private ClassLoader[] classLoaderOrder(PluginSource source) {
+        // By default, java and classgraph uses parent first classloading, 
hence if a plugin is loaded by the classpath
+        // loader, and then by an isolated plugin loader, the default 
precedence will always load the classpath version.
+        // This breaks isolation and hence connect uses isolated plugin 
loaders, which are child first classloaders.
+        // Therefore, we override the classloader order to be child first, so 
that the isolated plugin loader is used first.
+        // In addition, we need to explicitly specify the full classloader 
order, to force classgraph to scan classes in
+        // the class path. This does not happen by default as it uses 
reflections to obtain access to classpath URLs from
+        // the application classloader, which can fail with illegal access 
exceptions.

Review Comment:
   Can you update this comment with our current knowledge, and shorten it?



-- 
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]

Reply via email to