Fix Memory Leak in ExecuteScript on Jython
Moved module appending (aka classpath in python) into init stage instead of running each time onTrigger.
This closes
@@ -41,21 +41,23 @@ public class JythonScriptEngineConfigurator implements ScriptEngineConfigurator
@Override
public Object init(ScriptEngine engine, String[] modulePaths) throws ScriptException {
- return null;
- }
-
- @Override
- public Object eval(ScriptEngine engine, String scriptBody, String[] modulePaths) throws ScriptException {
- Object returnValue = null;
if (engine != null) {
// Need to import the module path inside the engine, in order to pick up
- // other Python/Jython modules
+ // other Python/Jython modules.
engine.eval("import sys");
if (modulePaths != null) {
for (String modulePath : modulePaths) {
engine.eval("sys.path.append('" + modulePath + "')");
}
}
+ }
+ return null;
+ }
+
+ @Override
+ public Object eval(ScriptEngine engine, String scriptBody, String[] modulePaths) throws ScriptException {
+ Object returnValue = null;
+ if (engine != null) {
returnValue = engine.eval(scriptBody);
}
return returnValue;
