Fix non-unique module handler identifiers #3592
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #3505
The cause is the naming of the module handlers. Internally the
BaseModuleHandlerFactory
stores the modules in aMap
where the key isruleUid+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 filefoo.rules
, the first rule gets afoo-1
, the 11th getsfoo-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 keyfoo-110
. When the 11th rule is added and has a trigger of the same type as first trigger, theBaseModuleHandlerFactory
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.