[jboss-jira] [JBoss JIRA] Commented: (JBRULES-1817) FactTemplateFieldExtractor must implement equals() method
Charles Daniels (JIRA)
jira-events at lists.jboss.org
Thu Jan 29 20:38:44 EST 2009
[ https://jira.jboss.org/jira/browse/JBRULES-1817?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12450330#action_12450330 ]
Charles Daniels commented on JBRULES-1817:
------------------------------------------
We are using version 4.0.7 and are not ready to upgrade to 5.x. Would someone please port this fix to 4.0.8?
> FactTemplateFieldExtractor must implement equals() method
> ---------------------------------------------------------
>
> Key: JBRULES-1817
> URL: https://jira.jboss.org/jira/browse/JBRULES-1817
> Project: JBoss Drools
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Components: drools-core
> Affects Versions: 4.0.7
> Environment: Sun JDK1.5.0_12 on Windows XP
> Reporter: Stephanie Kroll
> Assignee: Mark Proctor
> Fix For: 5.0.0.M5
>
>
> FactTemplateFieldExtractor does not implement equals(). This causes rules not to fire when the number of literal string equality constraints equals or exceeds the alpha node hashing threshold.
> To reproduce for the trivial case, I created the following rule package:
> package TestFactTemplate
> template MyFact
> String stringVal;
> end
> rule "Rule1"
> when
> MyFact (stringVal == "AA")
> then
> System.out.println("Rule1 fired");
> end
> rule "Rule2"
> when
> MyFact (stringVal == "AA")
> then
> System.out.println("Rule2 fired");
> end
> I implemented the Fact interface and returned "AA" from the two getFieldValue() methods. I also set the alphaNodeHashingThreshold to 2. When executing the rules, only Rule2 fires.
> If FactTemplateFieldExtractor implements equals() like so:
> public boolean equals(final Object object) {
> if ( this == object ) {
> return true;
> }
> if ( !(object instanceof FactTemplateFieldExtractor) ) {
> return false;
> }
> final FactTemplateFieldExtractor other = (FactTemplateFieldExtractor) object;
> return this.factTemplate.equals(other.factTemplate) &&
> this.fieldIndex == other.fieldIndex;
> }
> then both rules fire.
> The problem arises because without the equals() method for the field extractor, the LiteralConstraints do not report as equal, and the network does not reuse the nodes in BuildUtils.attachNode. When CompositeObjectSinkAdapter hashes the sinks because the threshold is met, only the last one is preserved in the hashedSinkMap since the HashKeys are the same.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list