[
https://jira.jboss.org/browse/JBRULES-2482?page=com.atlassian.jira.plugin...
]
Edson Tirelli commented on JBRULES-2482:
----------------------------------------
Hi Chris, thanks for reporting and providing test case.
Unfortunately the problem is not the offset vs index thing. Index is just an arbitrary
sequential number assigned according to the order in which Patterns are written in a given
rule. Offset, on the other hand, corresponds to the actual position of an object matching
that pattern inside a tuple. So offset must be used when resolving declarations against
objects in a given tuple.
Debugging the problem I found that contrary to the java dialect, the mvel dialect is
caching Declaration instances. It happens, though, that when a rule contains an
"or" statement (and in a few other cases), declarations must be cloned and
updated. That was happening for regular constraints, but not for eval expressions. That is
not a problem for the java dialect because it does not cache declarations, but it is a
problem for the mvel dialect for the same reason.
I am fixing this now.
Binding seems to be unreliable with MVEL dialect and mulitple evals
-------------------------------------------------------------------
Key: JBRULES-2482
URL:
https://jira.jboss.org/browse/JBRULES-2482
Project: Drools
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: drools-core (expert)
Affects Versions: 5.1.0.M1
Environment: Windows 7, Sun JDK 1.6.0_17
Reporter: Chris DeLashmutt
Assignee: Edson Tirelli
Attachments: mvel-binding-problem.zip, patch.txt.txt
When using the MVEL dialect, a rule with multiple binds, and a chain of evals, the
bindings seem to be incorrect.
For example here is some DRL:
rule "Modify Field Rule for Form: InterrelatedFieldsTestForm.fieldA (Set fieldA
optional if values are in other fields)"
when
$fieldA: Field(id == "fieldA")
$fieldB: Field(id == "fieldB")
$fieldC: Field(id == "fieldC")
(eval(ValidationFunctions.isChecked($fieldA)) or
eval(ValidationFunctions.isChecked($fieldB)) or
eval(!ValidationFunctions.isBlank($fieldC)))
then
ValidationFunctions.insertOperation(fieldOperations, new
FieldOperation("fieldA",FieldOperation.OPTIONAL));
end
If I put debugging statements in to the static ValidationFunctions methods, or if I put
breakpoints in those same static methods, I see invocations using bound variables that
don't match what I declared.
For instance, I'll see isBlank called with what appears to be the contents of
$fieldA.
If I combine the evals into a single eval with each condition separated by ||. everything
seems to function properly. I can't easily go back and change the syntax in my
exisiting rules however, and the syntax I'm using seems to be valid based on my
interpretation of the documentation.
--
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