You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by mc...@apache.org on 2018/01/08 21:42:38 UTC

nifi git commit: NIFI-4750 Ensuring preDestruction is called on authorizer and appropriate policy/user-group providers. This closes #2387

Repository: nifi
Updated Branches:
  refs/heads/master 8f635f1c0 -> 4196140e4


NIFI-4750 Ensuring preDestruction is called on authorizer and appropriate policy/user-group providers. This closes #2387


Project: http://git-wip-us.apache.org/repos/asf/nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/4196140e
Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/4196140e
Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/4196140e

Branch: refs/heads/master
Commit: 4196140e4c36a56957ea3c3bd3b5423f0731eda6
Parents: 8f635f1
Author: Bryan Bende <bb...@apache.org>
Authored: Mon Jan 8 16:21:03 2018 -0500
Committer: Matt Gilman <ma...@gmail.com>
Committed: Mon Jan 8 16:40:40 2018 -0500

----------------------------------------------------------------------
 .../authorization/AuthorizerFactoryBean.java    | 32 +++++++++++++++++++-
 .../CompositeConfigurableUserGroupProvider.java |  6 +++-
 .../CompositeUserGroupProvider.java             | 13 ++++++++
 3 files changed, 49 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi/blob/4196140e/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-authorizer/src/main/java/org/apache/nifi/authorization/AuthorizerFactoryBean.java
----------------------------------------------------------------------
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 7a5617c..9f17a18 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
@@ -479,7 +479,37 @@ public class AuthorizerFactoryBean implements FactoryBean, DisposableBean, UserG
     @Override
     public void destroy() throws Exception {
         if (authorizer != null) {
-            authorizer.preDestruction();
+            Exception error = null;
+
+            try {
+                authorizer.preDestruction();
+            } catch (final Exception e) {
+                error = e;
+            }
+
+            if (authorizer instanceof ManagedAuthorizer) {
+                final AccessPolicyProvider accessPolicyProvider = ((ManagedAuthorizer) authorizer).getAccessPolicyProvider();
+                if (accessPolicyProvider != null) {
+                    try {
+                        accessPolicyProvider.preDestruction();
+                    } catch (final Exception e) {
+                        error = e;
+                    }
+
+                    final UserGroupProvider userGroupProvider = accessPolicyProvider.getUserGroupProvider();
+                    if (userGroupProvider != null) {
+                        try {
+                            userGroupProvider.preDestruction();
+                        } catch (final Exception e) {
+                            error = e;
+                        }
+                    }
+                }
+            }
+
+            if (error != null) {
+                throw error;
+            }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/nifi/blob/4196140e/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/CompositeConfigurableUserGroupProvider.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/CompositeConfigurableUserGroupProvider.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/CompositeConfigurableUserGroupProvider.java
index 2140926..a262197 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/CompositeConfigurableUserGroupProvider.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/CompositeConfigurableUserGroupProvider.java
@@ -210,6 +210,10 @@ public class CompositeConfigurableUserGroupProvider extends CompositeUserGroupPr
 
     @Override
     public void preDestruction() throws AuthorizerDestructionException {
-        super.preDestruction();
+        try {
+            configurableUserGroupProvider.preDestruction();
+        } finally {
+            super.preDestruction();
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/nifi/blob/4196140e/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/CompositeUserGroupProvider.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/CompositeUserGroupProvider.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/CompositeUserGroupProvider.java
index 5f35191..916865b 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/CompositeUserGroupProvider.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/CompositeUserGroupProvider.java
@@ -199,5 +199,18 @@ public class CompositeUserGroupProvider implements UserGroupProvider {
 
     @Override
     public void preDestruction() throws AuthorizerDestructionException {
+        Exception error = null;
+        for (final UserGroupProvider userGroupProvider : userGroupProviders) {
+            try {
+                userGroupProvider.preDestruction();
+            } catch (Exception e) {
+                error = e;
+                logger.error("Error pre-destructing: " + e);
+            }
+        }
+
+        if (error != null) {
+            throw new AuthorizerDestructionException(error);
+        }
     }
 }