Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Commit

Permalink
update script engine initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmay48 committed Sep 12, 2023
1 parent cad289c commit 43fe39e
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

public class ScriptEvaluator {

private static final ScriptEngine engine = new NashornScriptEngineFactory().getScriptEngine();
private static ScriptEngine engine;

private ScriptEvaluator() {}

Expand All @@ -46,6 +46,9 @@ public static Boolean evalBool(String script, Object input) throws ScriptExcepti
* @return Generic object, the result of the evaluated expression.
*/
public static Object eval(String script, Object input) throws ScriptException {
if (engine == null) {
engine = new NashornScriptEngineFactory().getScriptEngine();
}
Bindings bindings = engine.createBindings();
bindings.put("$", input);
return engine.eval(script, bindings);
Expand Down

0 comments on commit 43fe39e

Please sign in to comment.