Shubhamjain007 / openhab

Automatically exported from code.google.com/p/openhab
0 stars 0 forks source link

Only the Time-bases rules from the last modified rule-file are executed #121

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. create two different rule-files with each containing at least one 
time-triggered rule
2. modify an save one of the files while runtime is running in order to get the 
runtime to reload it

What is the expected output? What do you see instead?
After reloading you see that the time triggered rules from the modified files 
are beeing rescheduled
"Scheduled rule xxx with cron expression xxx"

It seems that at this point the whole schedule has been overwritten and 
contains only the rules from the last modified file.
The other time based rules are not going to be triggered anymore.

What version of the product are you using? On what operating system?
OpenHAB 1.0 on Ubuntu Linux 12.04

Original issue reported on code.google.com by TBraeuti...@gmail.com on 7 Sep 2012 at 4:12

GoogleCodeExporter commented 8 years ago
I did some further investigation on this problem. From my point of view the 
error occurs because, when a rule-File has been changed the 
removeRuleModel(RuleModel ruleModel) method in RuleTriggermanager is executed. 
In this method the rules of all available types are removed from the list if 
they are part of the given RuleModel. But the time-based rules are removed 
independently from the given rule model.
I think if we add an additional test there, e.g. something similar to this:

for(Rule rule : new ArrayList<Rule>(timerEventTriggeredRules)) {
    if (ruleModel.getRules().contains(rule)) {
        removeRule(TIMER, rule);
    }
}

This example does not work, maybe someone could give me a hint on how to test 
if an time based rule is part of a RuleModel.

Original comment by TBraeuti...@gmail.com on 6 Oct 2012 at 4:13

GoogleCodeExporter commented 8 years ago
I think  found the reason why the code modification from my last comment 
doesn´t work. The removeRuleModel method is called with the already updated 
RuleModel, which contains new rule objects, which are not equal to the old ones 
(even if there are no changes, I guess?).
To fix this one could add a new EventType (e.g. BEFORE_MODIFIED) which is 
called reight before the modified RuleModel is updated. This triggers the 
removeRuleModel with the old RuleModel and all rule within this model are going 
to be removed correctly.

Original comment by TBraeuti...@gmail.com on 7 Oct 2012 at 9:32

GoogleCodeExporter commented 8 years ago

Original comment by kai.openhab on 7 Oct 2012 at 7:16

GoogleCodeExporter commented 8 years ago
Thanks a lot for reporting this bug, it should be fixed now.

Changeset: 
http://code.google.com/p/openhab/source/detail?r=ebf752ce45f64795ee781cd86aa6fa5
f184420e7

Original comment by kai.openhab on 7 Oct 2012 at 8:02