You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by olegz <gi...@git.apache.org> on 2017/03/01 18:10:35 UTC

[GitHub] nifi pull request #1539: NIFI-3520 Updates classloading for components annot...

Github user olegz commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1539#discussion_r103750596
  
    --- Diff: nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-nar-utils/src/main/java/org/apache/nifi/nar/ExtensionManager.java ---
    @@ -199,8 +199,20 @@ public static ClassLoader getClassLoader(final String classType, final String in
                 // then make a new InstanceClassLoader that is a full copy of the NAR Class Loader, otherwise create an empty
                 // InstanceClassLoader that has the NAR ClassLoader as a parent
                 if (requiresInstanceClassLoading.contains(classType) && (registeredClassLoader instanceof URLClassLoader)) {
    -                final URLClassLoader registeredUrlClassLoader = (URLClassLoader) registeredClassLoader;
    -                instanceClassLoader = new InstanceClassLoader(instanceIdentifier, classType, registeredUrlClassLoader.getURLs(), registeredUrlClassLoader.getParent());
    +                final Set<URL> classLoaderResources = new HashSet<>();
    +
    +                // if the registered class loader is a NAR class loader then walk the chain of class loaders until
    +                // finding a non-NAR class loader, and build up a list of all URLs along the way
    +                while (registeredClassLoader != null && registeredClassLoader instanceof NarClassLoader) {
    +                    final NarClassLoader narClassLoader = (NarClassLoader) registeredClassLoader;
    +                    for (URL classLoaderResource : narClassLoader.getURLs()) {
    +                        classLoaderResources.add(classLoaderResource);
    +                    }
    +                    registeredClassLoader = narClassLoader.getParent();
    +                }
    --- End diff --
    
    Perhaps this logic belongs in ```org.apache.nifi.util.file.classloader.ClassLoaderUtils```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---