diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/StandardProcessorNode.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/StandardProcessorNode.java index 5556e5a279..81a858319e 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/StandardProcessorNode.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/StandardProcessorNode.java @@ -105,6 +105,7 @@ import java.util.concurrent.Callable; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Future; +import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; @@ -1799,8 +1800,15 @@ public class StandardProcessorNode extends ProcessorNode implements Connectable return null; }; - // Trigger the task in a background thread. - final Future taskFuture = schedulingAgentCallback.scheduleTask(startupTask); + final Future taskFuture; + try { + // Trigger the task in a background thread. + taskFuture = schedulingAgentCallback.scheduleTask(startupTask); + } catch (RejectedExecutionException rejectedExecutionException) { + final ValidationState validationState = getValidationState(); + LOG.error("Unable to start {}. Last known validation state was {} : {}", this, validationState, validationState.getValidationErrors(), rejectedExecutionException); + return; + } // Trigger a task periodically to check if @OnScheduled task completed. Once it has, // this task will call SchedulingAgentCallback#onTaskComplete. diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/service/StandardControllerServiceNode.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/service/StandardControllerServiceNode.java index fccfbf99fd..811fa9933c 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/service/StandardControllerServiceNode.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/service/StandardControllerServiceNode.java @@ -76,6 +76,7 @@ import java.util.Map.Entry; import java.util.Optional; import java.util.Set; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; @@ -588,7 +589,12 @@ public class StandardControllerServiceNode extends AbstractComponentNode impleme LOG.debug("Cannot enable {} because it is not currently valid. (Validation State is {}: {}). Will try again in 1 second", StandardControllerServiceNode.this, validationState, validationState.getValidationErrors()); - scheduler.schedule(this, 1, TimeUnit.SECONDS); + try { + scheduler.schedule(this, 1, TimeUnit.SECONDS); + } catch (RejectedExecutionException rejectedExecutionException) { + LOG.error("Unable to enable {}. Last known validation state was {} : {}", StandardControllerServiceNode.this, validationState, validationState.getValidationErrors(), + rejectedExecutionException); + } future.complete(null); return; }