diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java index 5a017365d3..d00b73a92b 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java @@ -303,6 +303,7 @@ import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.UUID; +import java.util.concurrent.TimeUnit; import java.util.function.Function; import java.util.function.Predicate; import java.util.function.Supplier; @@ -314,6 +315,7 @@ import java.util.stream.Stream; */ public class StandardNiFiServiceFacade implements NiFiServiceFacade { private static final Logger logger = LoggerFactory.getLogger(StandardNiFiServiceFacade.class); + private static final int VALIDATION_WAIT_MILLIS = 50; // nifi core components private ControllerFacade controllerFacade; @@ -660,7 +662,10 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { final RevisionUpdate snapshot = updateComponent(revision, processorNode, () -> processorDAO.updateProcessor(processorDTO), - proc -> dtoFactory.createProcessorDto(proc)); + proc -> { + awaitValidationCompletion(proc); + return dtoFactory.createProcessorDto(proc); + }); final PermissionsDTO permissions = dtoFactory.createPermissionsDto(processorNode); final ProcessorStatusDTO status = dtoFactory.createProcessorStatusDto(controllerFacade.getProcessorStatus(processorNode.getIdentifier())); @@ -669,6 +674,10 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { return entityFactory.createProcessorEntity(snapshot.getComponent(), dtoFactory.createRevisionDTO(snapshot.getLastModification()), permissions, status, bulletinEntities); } + private void awaitValidationCompletion(final ComponentNode component) { + component.getValidationStatus(VALIDATION_WAIT_MILLIS, TimeUnit.MILLISECONDS); + } + @Override public LabelEntity updateLabel(final Revision revision, final LabelDTO labelDTO) { final Label labelNode = labelDAO.getLabel(labelDTO.getId()); @@ -2192,6 +2201,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { controllerService, () -> controllerServiceDAO.updateControllerService(controllerServiceDTO), cs -> { + awaitValidationCompletion(cs); final ControllerServiceDTO dto = dtoFactory.createControllerServiceDto(cs); final ControllerServiceReference ref = controllerService.getReferences(); final ControllerServiceReferencingComponentsEntity referencingComponentsEntity = @@ -2582,7 +2592,10 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { final RevisionUpdate snapshot = updateComponent(revision, reportingTask, () -> reportingTaskDAO.updateReportingTask(reportingTaskDTO), - rt -> dtoFactory.createReportingTaskDto(rt)); + rt -> { + awaitValidationCompletion(rt); + return dtoFactory.createReportingTaskDto(rt); + }); final PermissionsDTO permissions = dtoFactory.createPermissionsDto(reportingTask); final List bulletins = dtoFactory.createBulletinDtos(bulletinRepository.findBulletinsForSource(reportingTask.getIdentifier()));