kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject [kafka] branch 0.11.0 updated: KAFKA-6914; Set parent classloader of DelegatingClassLoader same as the worker's (#5720)
Date Fri, 05 Oct 2018 19:52:00 GMT
This is an automated email from the ASF dual-hosted git repository.

jgus pushed a commit to branch 0.11.0
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/0.11.0 by this push:
     new fa2039f  KAFKA-6914; Set parent classloader of DelegatingClassLoader same as the
worker's (#5720)
fa2039f is described below

commit fa2039fc1e5eb73c8897634a27f7ccda66719ab8
Author: Konstantine Karantasis <konstantine@confluent.io>
AuthorDate: Fri Oct 5 12:46:13 2018 -0700

    KAFKA-6914; Set parent classloader of DelegatingClassLoader same as the worker's (#5720)
    
    The parent classloader of the DelegatingClassLoader and therefore the classloading scheme
used by Connect does not have to be fixed to the System classloader.
    
    Setting it the same as the one that was used to load the DelegatingClassLoader class itself
is more flexible and, while in most cases will result in the System classloader to be used,
it will also work in othr managed environments that control classloading differently (OSGi,
and others).
    
    The fix is minimal and the mainstream use is tested via system tests.
    
    Reviewers: Randall Hauch <rhauch@gmail.com>, Jason Gustafson <jason@confluent.io>
---
 .../kafka/connect/runtime/isolation/DelegatingClassLoader.java      | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/isolation/DelegatingClassLoader.java
b/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/isolation/DelegatingClassLoader.java
index 886b415..83371b4 100644
--- a/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/isolation/DelegatingClassLoader.java
+++ b/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/isolation/DelegatingClassLoader.java
@@ -71,7 +71,11 @@ public class DelegatingClassLoader extends URLClassLoader {
     }
 
     public DelegatingClassLoader(List<String> pluginPaths) {
-        this(pluginPaths, ClassLoader.getSystemClassLoader());
+        // Use as parent the classloader that loaded this class. In most cases this will
be the
+        // System classloader. But this choice here provides additional flexibility in managed
+        // environments that control classloading differently (OSGi, Spring and others) and
don't
+        // depend on the System classloader to load Connect's classes.
+        this(pluginPaths, DelegatingClassLoader.class.getClassLoader());
     }
 
     public Set<PluginDesc<Connector>> connectors() {


Mime
View raw message