mattyb149 commented on a change in pull request #5116:
URL: https://github.com/apache/nifi/pull/5116#discussion_r645878298



##########
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:
       Yeah there might be a couple spots where the check should be done, 
probably a copy-paste error, I'll take a look. Good catch!
   
   I think the script engines we include that can actually subclass a Processor 
or other component are all Invocable, but we should check here defensively.




-- 
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]


Reply via email to