Skip to content

Commit

Permalink
[rules] Don't attempt to pre-compile disabled rules (#4329)
Browse files Browse the repository at this point in the history
Fixes an issue, where an error that compilation failed for disabled rules.
Reported on the community: https://community.openhab.org/t/oh-4-2-snapshot-disabled-rules-failed-to-compile-error-in-opehab-log/157402.
Follow-up for #4289.

Signed-off-by: Florian Hotze <[email protected]>
  • Loading branch information
florian-h05 authored Jul 24, 2024
1 parent f502e9d commit e157448
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1555,15 +1555,16 @@ public void onReadyMarkerRemoved(ReadyMarker readyMarker) {
}

/**
* This method compiles the conditions and actions of all rules. It is called when the rule engine is started.
* This method compiles the conditions and actions of all enabled rules.
* It is called when the rule engine is started.
* By compiling when the rule engine is started, we make sure all conditions and actions are compiled, even if their
* handlers weren't available when the rule was added to the rule engine.
*/
private void compileRules() {
getScheduledExecutor().submit(() -> {
ruleRegistry.getAll().forEach(r -> {
compileRule(r.getUID());
});
ruleRegistry.getAll().stream() //
.filter(r -> isEnabled(r.getUID())) //
.forEach(r -> compileRule(r.getUID()));
executeRulesWithStartLevel();
});
}
Expand Down

0 comments on commit e157448

Please sign in to comment.