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 7a5617cf47..9f17a18ae5 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; + } } } 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 21409266ac..a2621979a7 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(); + } } } 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 5f351912b4..916865be80 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); + } } }