NIFI-250: - Adding a check to ensure we don't attempt to reload a controller service that has been removed but is still referenced by another controller service.
Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/be3254c9 Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/be3254c9 Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/be3254c9 Branch: refs/heads/NIFI-250 Commit: be3254c947352486e5fe992184f8de6a5b20369f Parents: 21ab41f Author: Matt Gilman <[email protected]> Authored: Fri Mar 27 09:22:22 2015 -0400 Committer: Matt Gilman <[email protected]> Committed: Fri Mar 27 09:22:22 2015 -0400 ---------------------------------------------------------------------- .../webapp/js/nf/canvas/nf-controller-service.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/be3254c9/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.js ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.js b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.js index 8640f4e..9371cfc 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.js +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.js @@ -135,6 +135,15 @@ nf.ControllerService = (function () { var controllerServiceData = controllerServiceGrid.getData(); var controllerService = controllerServiceData.getItemById(id); + // this may happen if controller service A references another controller + // service B that has been removed. attempting to enable/disable/remove A + // will attempt to reload B which is no longer a known service + if (nf.Common.isUndefined(controllerService)) { + return $.Deferred(function (deferred) { + deferred.reject(); + }).promise(); + } + return $.ajax({ type: 'GET', url: controllerService.uri, @@ -1580,7 +1589,7 @@ nf.ControllerService = (function () { */ enable: function(controllerService) { if (nf.Common.isEmpty(controllerService.referencingComponents)) { - setEnabled(controllerService, true).always(function () { + setEnabled(controllerService, true).done(function () { reloadControllerServiceAndReferencingComponents(controllerService); }); } else { @@ -1595,7 +1604,7 @@ nf.ControllerService = (function () { */ disable: function(controllerService) { if (nf.Common.isEmpty(controllerService.referencingComponents)) { - setEnabled(controllerService, false).always(function () { + setEnabled(controllerService, false).done(function () { reloadControllerServiceAndReferencingComponents(controllerService); }); } else { @@ -1614,6 +1623,8 @@ nf.ControllerService = (function () { $.each(component.descriptors, function(_, descriptor) { if (descriptor.identifiesControllerService === true) { var referencedServiceId = component.properties[descriptor.name]; + + // ensure the property is configured if (nf.Common.isDefinedAndNotNull(referencedServiceId) && $.trim(referencedServiceId).length > 0) { reloadControllerService(referencedServiceId); }
