[rules-users] A Set of Rules but no match

Wolfgang Laun wolfgang.laun at gmail.com
Thu Aug 5 13:52:21 EDT 2010


My patch adding hashCode and equals has been applied by Edson.

-W


On 5 August 2010 13:09, Wolfgang Laun <wolfgang.laun at gmail.com> wrote:

> I'm using code such as
>
> KnowledgeRuntime knowledgeRuntime;
> for( KnowledgePackage knowledgePackage:
> knowledgeRuntime.getKnowledgeBase().getKnowledgePackages() ){
>        for( Rule rule: knowledgePackage.getRules() ){
>        }
> }
>
> to obtain rules, intending to construct a Set<Rule>. This, however, breaks
> since repeated executions of
> knowledgePackage.getRules() appear to return different objects and - this
> is the evil thing -
> org.drools.definitions.rule.impl.RuleImpl does not implement hashCode() and
> equals(); hence
> Set<Rules>( rule ).contains( rule ) fails for actually identical rules. I
> consider this a bug in Drools (5.1).
>
> org.drools.definitions.rule.impl.RuleImpl could easily retain a reference
> to
> the org.drools.rule.Rule object from which it is built and delegate
> hashCode/equals to that.
>
> -W
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20100805/9c2c6609/attachment.html 


More information about the rules-users mailing list