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

Inconsistent rule map usage in XMLParser initRules method #13

Open
kenj1 opened this issue Jan 31, 2013 · 1 comment
Open

Inconsistent rule map usage in XMLParser initRules method #13

kenj1 opened this issue Jan 31, 2013 · 1 comment

Comments

@kenj1
Copy link

kenj1 commented Jan 31, 2013

Hello. In reviewing the XMLParser class code, I noticed that the initRules method looks up the rule key as a String but put's it into the same map as an int (hashCode). This may be a missed change when you improved the parse performance rule lookup from String to Hashcode. This issue shows up in all 3 rules maps.

The net result is a location path will always create a new rulelist and thus only ever have one rule associated with it (last rule definition wins for that path). This could lead to wasted memory and/or unexpected behavior.

KenJ

@ghost
Copy link

ghost commented Feb 4, 2013

Ken, great catch!

Leaving a quick note for myself, the issue Ken is reporting can be easily seen in initRules with any of the switch-case statements where the rule is attempted lookup by its name, then stored by its hashcode:

// Get the rule list for this path
ruleList = tagRuleMap.get(rule.getLocationPath());

// If there wasn't already a rule list, create and add it
if (ruleList == null) {
    ruleList = new ArrayList<IRule<T>>(3);
    tagRuleMap.put(rule.getLocationPath().hashCode(), ruleList);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant