[jboss-jira] [JBoss JIRA] Resolved: (JBRULES-2526) org.drools.rule.InvalidPatternException: "Required Declarations not bound" when using MVEL, and OR-ing evals together
Edson Tirelli (JIRA)
jira-events at lists.jboss.org
Wed Jun 2 13:27:45 EDT 2010
[ https://jira.jboss.org/browse/JBRULES-2526?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Edson Tirelli resolved JBRULES-2526.
------------------------------------
Fix Version/s: 5.1.0.CR1
Resolution: Done
Thanks for reporting and providing the test case.
The problem was that eval statements were not properly cloned for each logical branch. That was not a problem for the java dialect that uses "stateless" expressions, but MVEL dialect caches declarations and when wiring them, each logical branch was overriding the wired declarations of the previous logical branch.
Fixed.
> org.drools.rule.InvalidPatternException: "Required Declarations not bound" when using MVEL, and OR-ing evals together
> ----------------------------------------------------------------------------------------------------------------------
>
> Key: JBRULES-2526
> URL: https://jira.jboss.org/browse/JBRULES-2526
> Project: Drools
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Components: drools-core (expert)
> Affects Versions: 5.1.0.CR1
> Reporter: Chris DeLashmutt
> Assignee: Edson Tirelli
> Fix For: 5.1.0.CR1
>
> Attachments: mvel-declarations-problem.zip
>
>
> There is an issue when using multiple groups of OR'd evals and the mvel dialect. Drools is throwing an InvalidPatternException complaining that there are unbound declarations. During tracing, it seems that the declaration was actually found, but offset for the pattern that is resolved in BuildUtils.checkUnboundDeclarations() line: 239 isn't <= the offset of the pattern that was passed in with the declarations to the method.
> Here is the rule:
> rule "MVEL with OR groups and Evals"
> when
> $fieldB: Field(name == "fieldB")
> $fieldC: Field(name == "fieldC")
> $fieldD: Field(name == "fieldD")
> $fieldE: Field(name == "fieldE")
> (
> eval($fieldB != null)
> || eval($fieldC != null)
> )
> (
> eval($fieldD != null)
> || eval($fieldE != null)
> )
> then
> insert( new Result("Found") );
> end
> Here is the stack trace:
> Thread [main] (Suspended (exception InvalidPatternException))
> BuildUtils.checkUnboundDeclarations(BuildContext, Declaration[]) line: 258
> EvalBuilder.build(BuildContext, BuildUtils, RuleConditionElement) line: 40
> GroupElementBuilder$AndBuilder.build(BuildContext, BuildUtils, RuleConditionElement) line: 130
> GroupElementBuilder.build(BuildContext, BuildUtils, RuleConditionElement) line: 77
> ReteooRuleBuilder.addSubRule(BuildContext, GroupElement, Rule) line: 155
> ReteooRuleBuilder.addRule(Rule, InternalRuleBase, IdGenerator) line: 128
> ReteooBuilder.addRule(Rule) line: 117
> ReteooRuleBase.addRule(Rule) line: 409
> ReteooRuleBase(AbstractRuleBase).addRule(Package, Rule) line: 638
> ReteooRuleBase(AbstractRuleBase).addPackages(Collection<Package>) line: 520
> ReteooRuleBase.addPackage(Package) line: 435
> TestDeclarations.testDeclarations() line: 41
> ... (some stack removed for clarity)
> RemoteTestRunner.main(String[]) line: 197
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list