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 non-unique module handler identifiers #3592

Merged
merged 1 commit into from
May 5, 2023
Merged

Conversation

J-N-K
Copy link
Member

@J-N-K J-N-K commented May 5, 2023

Fixes #3505

The cause is the naming of the module handlers. Internally the BaseModuleHandlerFactory stores the modules in a Map where the key is ruleUid+moduleId.

Textual defined rules have ruleUid that consists of the filename, a dash and a number that denotes the position of the rule in the file, so in a file foo.rules, the first rule gets a foo-1, the 11th gets foo-11. Within a rule, the modules are numbered from 0 to n. So the if the first rule has 10 triggers, the last module handler is stored with a key foo-110. When the 11th rule is added and has a trigger of the same type as first trigger, the BaseModuleHandlerFactory generates the same key and returns the already created handler for 10th trigger of rule 1 instead creating a new handler.

This PR changes the key to <ruleUid>$<moduleId>. This should be safe because $ is not an allowed character for the module id and collisions are prevented.

Signed-off-by: Jan N. Klug <github@klug.nrw>
@J-N-K J-N-K added the bug An unexpected problem or unintended behavior of the Core label May 5, 2023
@J-N-K J-N-K requested a review from a team as a code owner May 5, 2023 15:14
Copy link
Member

@kaikreuzer kaikreuzer left a comment

Choose a reason for hiding this comment

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

Thanks, interesting effect.

@kaikreuzer kaikreuzer merged commit 28ec419 into openhab:main May 5, 2023
@kaikreuzer kaikreuzer added this to the 4.0 milestone May 5, 2023
@J-N-K J-N-K deleted the bug-mhi branch May 5, 2023 20:23
splatch pushed a commit to ConnectorIO/copybara-hab-core that referenced this pull request Jul 12, 2023
Signed-off-by: Jan N. Klug <github@klug.nrw>
GitOrigin-RevId: 28ec419
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of the Core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrong Rule triggered by item
2 participants