mattyb149 commented on a change in pull request #5116:
URL: https://github.com/apache/nifi/pull/5116#discussion_r646650078
##########
File path:
nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/record/sink/script/ScriptedRecordSink.java
##########
@@ -217,26 +211,31 @@ public void onEnabled(final ConfigurationContext context)
{
super.onEnabled(context);
// Call an non-interface method onEnabled(context), to allow a
scripted RecordSinkService the chance to set up as necessary
- final Invocable invocable = (Invocable) scriptEngine;
- if (configurationContext != null) {
- try {
- // Get the actual object from the script engine, versus the
proxy stored in RecordSinkService. The object may have additional methods,
- // where RecordSinkService is a proxied interface
- final Object obj = scriptEngine.get("recordSink");
- if (obj != null) {
- try {
- invocable.invokeMethod(obj, "onEnabled", context);
- } catch (final NoSuchMethodException nsme) {
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("Configured script
RecordSinkService does not contain an onEnabled() method.");
+ if (scriptRunner != null) {
+ final ScriptEngine scriptEngine = scriptRunner.getScriptEngine();
+ final Invocable invocable = (Invocable) scriptEngine;
Review comment:
I decided to update the `createResources()` method to take a boolean
(defaulting to true) to indicate whether the supported script engines are
required to be Invocable. I'll change ExecuteScript to call it with false, and
the rest will only allow a choice of an Invocable engine, so the individual
checks should be unnecessary.
--
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]