NissimShiman commented on code in PR #6829:
URL: https://github.com/apache/nifi/pull/6829#discussion_r1066085426


##########
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/StandardProcessorNode.java:
##########
@@ -1799,8 +1800,15 @@ private void initiateStart(final 
ScheduledExecutorService taskScheduler, final l
             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;

Review Comment:
   Thank for @mattyb149 very much for looking at this (as well as NIFI-10608 
just last week as well)!
   
   Nice observations...  
   
   I just tested this with throwing the exception instead of returning and we 
end up with the stack trace in the logs an additional time (with the second 
stack trace time starting with the additional line of ["Uncaught Exception in 
Runnable 
Task"](https://github.com/apache/nifi/blob/rel/nifi-1.19.1/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/engine/FlowEngine.java#L112)
 )
   so if I am understanding this correctly, returning looks to be cleaner in 
this case.
   
   I also tried to see what happens when not returning or re-throwing in the 
catch block and the code fails/crashes shortly afterwards.  (yeah... that would 
have been pretty neat if somehow we could work a way to get the processor to 
start)
   
   The try block unsuccessfully initializes 
[taskFuture](https://github.com/apache/nifi/blob/dbd3a88ac55112812138b048221c1dc35c5ecdad/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/StandardProcessorNode.java#L1806)
   
   which is needed [a little 
later](https://github.com/apache/nifi/blob/dbd3a88ac55112812138b048221c1dc35c5ecdad/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/StandardProcessorNode.java#L1827)
   
   Normally, when a processor has no issues/no exceptions, then it sails 
through this code and starts right up, but if there is an exception then we are 
stuck.
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to