This is an automated email from the ASF dual-hosted git repository.

mcgilman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/master by this push:
     new dd62068  NIFI-6904 Moving ClassLoader creation before Authorizer 
instantiation
dd62068 is described below

commit dd620680b1e3e053acfc7c1b1e3f000de57351c8
Author: Bryan Bende <[email protected]>
AuthorDate: Mon Nov 25 09:13:20 2019 -0500

    NIFI-6904 Moving ClassLoader creation before Authorizer instantiation
    
    This closes #3903
---
 .../apache/nifi/authorization/AuthorizerFactoryBean.java  | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-authorizer/src/main/java/org/apache/nifi/authorization/AuthorizerFactoryBean.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-authorizer/src/main/java/org/apache/nifi/authorization/AuthorizerFactoryBean.java
index 1e12264..9d18e03 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-authorizer/src/main/java/org/apache/nifi/authorization/AuthorizerFactoryBean.java
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-authorizer/src/main/java/org/apache/nifi/authorization/AuthorizerFactoryBean.java
@@ -158,7 +158,7 @@ public class AuthorizerFactoryBean implements FactoryBean, 
DisposableBean, UserG
                         if 
(authorizers.containsKey(authorizer.getIdentifier())) {
                             throw new Exception("Duplicate Authorizer 
identifier in Authorizers configuration: " + authorizer.getIdentifier());
                         }
-                        authorizers.put(authorizer.getIdentifier(), 
createAuthorizer(authorizer.getIdentifier(), 
authorizer.getClazz(),authorizer.getClasspath()));
+                        authorizers.put(authorizer.getIdentifier(), 
createAuthorizer(authorizer.getIdentifier(), authorizer.getClazz(), 
authorizer.getClasspath()));
                     }
 
                     // configure each authorizer
@@ -315,9 +315,17 @@ public class AuthorizerFactoryBean implements FactoryBean, 
DisposableBean, UserG
             throw new Exception(String.format("Multiple bundles found for the 
specified authorizer class '%s', only one is allowed.", authorizerClassName));
         }
 
+        // start with ClassLoad from authorizer's bundle
         final Bundle authorizerBundle = authorizerBundles.get(0);
         ClassLoader authorizerClassLoader = authorizerBundle.getClassLoader();
 
+        // if additional classpath resources were specified, replace with a 
new ClassLoader that wraps the original one
+        if (StringUtils.isNotEmpty(classpathResources)) {
+            logger.info(String.format("Replacing Authorizer ClassLoader for 
'%s' to include additional resources: %s", identifier, classpathResources));
+            URL[] urls = 
ClassLoaderUtils.getURLsForClasspath(classpathResources, null, true);
+            authorizerClassLoader = new URLClassLoader(urls, 
authorizerClassLoader);
+        }
+
         // get the current context classloader
         final ClassLoader currentClassLoader = 
Thread.currentThread().getContextClassLoader();
 
@@ -348,11 +356,6 @@ public class AuthorizerFactoryBean implements FactoryBean, 
DisposableBean, UserG
             }
         }
 
-        if (StringUtils.isNotEmpty(classpathResources)) {
-            URL[] urls = 
ClassLoaderUtils.getURLsForClasspath(classpathResources, null, true);
-            authorizerClassLoader = new URLClassLoader(urls, 
authorizerClassLoader);
-        }
-
         return AuthorizerFactory.withNarLoader(instance, 
authorizerClassLoader);
     }
 

Reply via email to