mirror of https://github.com/apache/nifi.git
NIFI-4750 Ensuring preDestruction is called on authorizer and appropriate policy/user-group providers. This closes #2387
This commit is contained in:
parent
8f635f1c0d
commit
4196140e4c
|
@ -479,7 +479,37 @@ public class AuthorizerFactoryBean implements FactoryBean, DisposableBean, UserG
|
||||||
@Override
|
@Override
|
||||||
public void destroy() throws Exception {
|
public void destroy() throws Exception {
|
||||||
if (authorizer != null) {
|
if (authorizer != null) {
|
||||||
|
Exception error = null;
|
||||||
|
|
||||||
|
try {
|
||||||
authorizer.preDestruction();
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -210,6 +210,10 @@ public class CompositeConfigurableUserGroupProvider extends CompositeUserGroupPr
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void preDestruction() throws AuthorizerDestructionException {
|
public void preDestruction() throws AuthorizerDestructionException {
|
||||||
|
try {
|
||||||
|
configurableUserGroupProvider.preDestruction();
|
||||||
|
} finally {
|
||||||
super.preDestruction();
|
super.preDestruction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -199,5 +199,18 @@ public class CompositeUserGroupProvider implements UserGroupProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void preDestruction() throws AuthorizerDestructionException {
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue