kafka-commits mailing list archives

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

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


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

commit 6a03d3b42cde89c921777d100c9107407f206de4
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 144dbd8..6104dd4 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
@@ -94,7 +94,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