kafka-commits mailing list archives

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

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


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

commit 788ebe839e429aaf20aad17e6fa88dfcf5b3aff7
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 8a44d4d..11f2bd0 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
@@ -74,7 +74,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