pgyori commented on a change in pull request #5116:
URL: https://github.com/apache/nifi/pull/5116#discussion_r646664759
##########
File path:
nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/processors/script/ExecuteScript.java
##########
@@ -223,14 +195,15 @@ public void onTrigger(ProcessContext context,
ProcessSessionFactory sessionFacto
scriptingComponentHelper.createResources();
Review comment:
This is not strictly relevant to this modification, but I found that if
we have 1 flowfile in the input queue and we start the processor with e.g. 3
concurrent threads, then onTrigger will be fully executed 3 times, and only 1
of the executions will have a flowfile to process. Usually this is avoided by
putting this in onTrigger:
`FlowFile incomingFlowFile = session.get();
if (incomingFlowFile == null) {
return;
}`
However, we cannot call session.get() in onTrigger in this case since it is
the script's task to get the flowfile. I did not find any means to check in the
beginning of onTrigger if the incoming queue is empty to avoid fully executing
it in such a case. Do you know any solution to this?
##########
File path:
nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/processors/script/ExecuteScript.java
##########
@@ -253,31 +226,16 @@ public void onTrigger(ProcessContext context,
ProcessSessionFactory sessionFacto
}
}
- scriptEngine.setBindings(bindings, ScriptContext.ENGINE_SCOPE);
-
- // Execute any engine-specific configuration before the script
is evaluated
- ScriptEngineConfigurator configurator =
-
scriptingComponentHelper.scriptEngineConfiguratorMap.get(scriptingComponentHelper.getScriptEngineName().toLowerCase());
-
- // Evaluate the script with the configurator (if it exists) or
the engine
- if (configurator != null) {
- configurator.init(scriptEngine, scriptToRun,
scriptingComponentHelper.getModules());
- configurator.eval(scriptEngine, scriptToRun,
scriptingComponentHelper.getModules());
- } else {
- scriptEngine.eval(scriptToRun);
- }
+ scriptRunner.run(bindings);
// Commit this session for the user. This plus the outermost
catch statement mimics the behavior
// of AbstractProcessor. This class doesn't extend
AbstractProcessor in order to share a base
// class with InvokeScriptedProcessor
session.commitAsync();
+ scriptingComponentHelper.scriptRunnerQ.offer(scriptRunner);
Review comment:
If this line is not in a finally block, then I think we might lose a
ScriptRunner if something throws a non-ScriptException Throwable in this method.
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]