Skip to content

Commit 8537a1b

Browse files
authored
Reintroduce a check with scriptEngineManager if the script type is supported before attempting to compile it (#4971)
It was removed in 8154dce (#4922) and might be causing the logging of errors during startup, as reported in #4965. Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
1 parent 73c9cbd commit 8537a1b

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/handler/AbstractScriptModuleHandler.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,12 @@ protected void compileScript() throws ScriptException {
9696
if (compiledScript.isPresent() || script.isEmpty()) {
9797
return;
9898
}
99-
99+
if (!scriptEngineManager.isSupported(type)) {
100+
logger.debug(
101+
"ScriptEngine for language '{}' could not be found, skipping compilation of script for identifier: {}",
102+
type, engineIdentifier);
103+
return;
104+
}
100105
Optional<ScriptEngine> engine = getScriptEngine();
101106
if (engine.isPresent()) {
102107
ScriptEngine scriptEngine = engine.get();
@@ -123,7 +128,7 @@ public synchronized void resetScriptEngine() {
123128

124129
/**
125130
* Gets the unique identifier of the rule this module handler is used for.
126-
*
131+
*
127132
* @return the UID of the rule
128133
*/
129134
public String getRuleUID() {
@@ -141,7 +146,7 @@ public String getEngineIdentifier() {
141146

142147
/**
143148
* Get the script engine instance used by this module handler.
144-
*
149+
*
145150
* @return the script engine instance if available, otherwise Optional.empty()
146151
*/
147152
protected Optional<ScriptEngine> getScriptEngine() {
@@ -150,7 +155,7 @@ protected Optional<ScriptEngine> getScriptEngine() {
150155

151156
/**
152157
* Creates a new script engine for the type defined in the module configuration.
153-
*
158+
*
154159
* @return the script engine if available, otherwise Optional.empty()
155160
*/
156161
private Optional<ScriptEngine> createScriptEngine() {

0 commit comments

Comments
 (0)