Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix context being re-used for next execution #2760

Merged
merged 2 commits into from
Feb 17, 2022

Conversation

J-N-K
Copy link
Member

@J-N-K J-N-K commented Feb 13, 2022

Fixes #2751

Trigger information is inserted in the execution context. This information is changed to the new information each time the context is updated with the same keys. If the context of the next execution does not contain values for each key, the old key is re-used, leading e.g. to wrong event information in the context.

The solution is to remove the content of the triggering context after each execution.

Signed-off-by: Jan N. Klug github@klug.nrw

Trigger information is inserted in the execution context. This information is changed to the new information each time the context is updated with the same keys. If the context of the next execution does not contain values for each key, the old key is re-used, leading e.g. to wrong event information in the context.

The solution is to re-set the individual context after each execution.

Signed-off-by: Jan N. Klug <github@klug.nrw>
@J-N-K J-N-K requested a review from a team as a code owner February 13, 2022 13:36
@cweitkamp cweitkamp added bug An unexpected problem or unintended behavior of the Core DSL rules Domain-Specific Language rules labels Feb 14, 2022
@J-N-K
Copy link
Member Author

J-N-K commented Feb 14, 2022

This is not just DSL, it affects all JSR-223 rule engines, too.

@openhab-bot
Copy link
Collaborator

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/rule-not-triggered-at-startup-when-second-trigger-is-configured/133198/17

@cweitkamp cweitkamp added automation and removed DSL rules Domain-Specific Language rules labels Feb 14, 2022
…a/org/openhab/core/automation/module/script/internal/handler/AbstractScriptModuleHandler.java
Copy link
Member

@wborn wborn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM and thanks!

@wborn wborn merged commit 6906927 into openhab:main Feb 17, 2022
@wborn wborn added this to the 3.3 milestone Feb 17, 2022
@J-N-K J-N-K deleted the bug-fix-context-leaking branch February 18, 2022 14:46
@openhab-bot
Copy link
Collaborator

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/triggeringitemname-fails-with-cron/135210/3

splatch pushed a commit to ConnectorIO/copybara-hab-core that referenced this pull request Jul 12, 2023
Trigger information is inserted in the execution context. This information is changed to the new information each time the context is updated with the same keys. If the context of the next execution does not contain values for each key, the old key is re-used, leading e.g. to wrong event information in the context.

The solution is to re-set the individual context after each execution.

Signed-off-by: Jan N. Klug <github@klug.nrw>
GitOrigin-RevId: 6906927
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automation bug An unexpected problem or unintended behavior of the Core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

event is defined during rule execution with startup trigger
4 participants