[
http://jira.jboss.com/jira/browse/JBRULES-1169?page=comments#action_12376481 ]
Edson Tirelli commented on JBRULES-1169:
----------------------------------------
Yuri,
Remember that inside eval() you are using plain java code, so comparing strings with
"==" in java will return true only if the strings are identical (same memory
address). That probably explains why your last expression evaluates to false.
Your rule(2) suffers from the same problem, and it is difficult to say why it is
incorrectly generating activations without looking at the whole code.
It is important to note that if your rules were being dynamically added to the rulebase,
it is possible that you were suffering the consequences of this bug, that I fixed in
trunk:
http://jira.jboss.com/jira/browse/JBRULES-1177
May I ask you please to either try your example with trunk or provide us a test case? You
can get latest build from here:
http://cruisecontrol.jboss.com/cc/artifacts/jboss-rules
I'm setting this ticket as resolved (not possible to reproduce bug in trunk), but
please reopen it if it is still a problem for you.
Thanks for reporting.
PredicateConstraint and/or MVEL Constraint issue?
-------------------------------------------------
Key: JBRULES-1169
URL:
http://jira.jboss.com/jira/browse/JBRULES-1169
Project: JBoss Rules
Issue Type: Bug
Security Level: Public(Everyone can see)
Affects Versions: 4.0.1
Reporter: Yuri de Wit
Assigned To: Edson Tirelli
Priority: Critical
Fix For: 4.0.2
Consider the following rules:
rule (1)
when
a: Criteria(
$criteriaA : criteriaA,
$criteriaB : criteriaB
)
b: Criteria(
matchCriteriaA == true && criteriaA == $criteriaA
|| matchCriteriaB == true && criteriaB == $criteriaB
)
then
...
end
rule (2)
when
a: Criteria(
$criteriaA : criteriaA,
$criteriaB : criteriaB
)
b: Criteria(
eval(
matchCriteriaA == true && criteriaA == $criteriaA
|| matchCriteriaB == true && criteriaB == $criteriaB
)
)
then
...
end
I am seeing different behavior for the same test cases. I am basically inserting
"a" and "b" with matching criteriaA and criteriaB and I am testing
different
combinations of matchCriteriaA and matchCriteriaB (i.e. F/F, F/T, T/F, T/T).
Results for rule (1):
F/F -> rule activated (incorrect)
T/F -> rule activated (correct)
F/T -> rule activated (correct)
Results for rule (2):
F/F -> rule activated (incorrect)
T/F -> rule activated (correct)
F/T -> rule activated (correct)
I also tried an eval column (now a snippet based on the actual rule I ran):
eval(
($t_matchDvpAccount == true && $t_accountCode == $c_accountCode)
|| ($t_matchPartialAccount == true && $t_accountCode5 == $c_accountCode5)
|| ($t_matchClientAccount == true && $t_clientAccountCode == $c_accountCode)
|| ($t_matchNoAccount == true)
)
And with the following data (took while debugging the evaluation):
$t_matchClientAccount Boolean (id=176) value false
$t_accountCode "123450ACCT"
$t_matchDvpAccount Boolean (id=176) value false
$t_matchPartialAccount Boolean (id=191) value true
$t_clientAccountCode "12345CACCT"
$c_accountCode5 "12345"
$t_accountCode5 "12345"
$t_matchNoAccount Boolean (id=176) value false
The evaluation returns false.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira