From 83b069d970e79d4880f8a367aa5ca2775a6674a7 Mon Sep 17 00:00:00 2001 From: jimtng <2554958+jimtng@users.noreply.github.com> Date: Tue, 10 Sep 2024 15:52:16 +1000 Subject: [PATCH] Revert "Insert context keys before compiling UI scripts (#4372)" (#4373) This reverts commit 6e6f000800dec137e14763eaeb595a5fce67fe15. Signed-off-by: Jimmy Tanagra --- .../script/internal/handler/AbstractScriptModuleHandler.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/handler/AbstractScriptModuleHandler.java b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/handler/AbstractScriptModuleHandler.java index 49e3b3a9f..6a695d6e7 100644 --- a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/handler/AbstractScriptModuleHandler.java +++ b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/handler/AbstractScriptModuleHandler.java @@ -105,7 +105,6 @@ public abstract class AbstractScriptModuleHandler extends Base ScriptEngine scriptEngine = engine.get(); if (scriptEngine instanceof Compilable) { logger.debug("Pre-compiling script of rule with UID '{}'", ruleUID); - setExecutionContext(scriptEngine, Map.of()); // JRuby script engine needs this before compiling compiledScript = Optional.ofNullable(((Compilable) scriptEngine).compile(script)); } } @@ -212,7 +211,7 @@ public abstract class AbstractScriptModuleHandler extends Base try { if (compiledScript.isPresent()) { logger.debug("Executing pre-compiled script of rule with UID '{}'", ruleUID); - return compiledScript.get().eval(); + return compiledScript.get().eval(engine.getContext()); } logger.debug("Executing script of rule with UID '{}'", ruleUID); return engine.eval(script);