NIFI-2642 Catches (and ignores) ResourceNotFoundException during the updating of a property value for a controller service when the current value points to a controller service that has been deleted, allowing the assigning of a new controller service to continue.

This closes #931
This commit is contained in:
Jeff Storck 2016-08-24 15:06:01 -04:00 committed by Oleg Zhurakousky
parent c2ae7a6d7c
commit 6475924f53
1 changed files with 7 additions and 2 deletions

View File

@ -20,6 +20,7 @@ import org.apache.nifi.authorization.resource.Authorizable;
import org.apache.nifi.authorization.user.NiFiUser; import org.apache.nifi.authorization.user.NiFiUser;
import org.apache.nifi.authorization.user.NiFiUserUtils; import org.apache.nifi.authorization.user.NiFiUserUtils;
import org.apache.nifi.components.PropertyDescriptor; import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.web.ResourceNotFoundException;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
@ -57,8 +58,12 @@ public final class AuthorizeControllerServiceReference {
if (!Objects.equals(currentValue, proposedValue)) { if (!Objects.equals(currentValue, proposedValue)) {
// ensure access to the old service // ensure access to the old service
if (currentValue != null) { if (currentValue != null) {
try {
final Authorizable currentServiceAuthorizable = lookup.getControllerService(currentValue).getAuthorizable(); final Authorizable currentServiceAuthorizable = lookup.getControllerService(currentValue).getAuthorizable();
currentServiceAuthorizable.authorize(authorizer, RequestAction.READ, user); currentServiceAuthorizable.authorize(authorizer, RequestAction.READ, user);
} catch (ResourceNotFoundException e) {
// ignore if the resource is not found, if currentValue was previously deleted, it should not stop assignment of proposedValue
}
} }
// ensure access to the new service // ensure access to the new service