You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2020/12/09 14:09:31 UTC

[GitHub] [nifi] markap14 commented on a change in pull request #4717: NIFI-8080: Compile Jython scripts before evaluating

markap14 commented on a change in pull request #4717:
URL: https://github.com/apache/nifi/pull/4717#discussion_r539335938



##########
File path: nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/script/impl/JythonScriptEngineConfigurator.java
##########
@@ -41,25 +48,27 @@ public String getScriptEngineName() {
     }
 
     @Override
-    public Object init(ScriptEngine engine, String[] modulePaths) throws ScriptException {
-        if (engine != null) {
-            // Need to import the module path inside the engine, in order to pick up
-            // other Python/Jython modules.
-            engine.eval("import sys");
-            if (modulePaths != null) {
-                for (String modulePath : modulePaths) {
-                    engine.eval("sys.path.append(" + PyString.encode_UnicodeEscape(modulePath, true) + ")");
-                }
-            }
-        }
+    public Object init(ScriptEngine engine, String[] modulePaths) {

Review comment:
       Previously, the init() method evaluated the script. Which means that if the script doesn't compile, the processor would be invalid. Now, with the init() method not compiling the script, does that mean that the processor will be valid even if the script is not compilable? Might make sense to compile in the init() method instead of the first iteration of eval?




----------------------------------------------------------------
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:
users@infra.apache.org