[
https://issues.jboss.org/browse/JBRULES-3302?page=com.atlassian.jira.plug...
]
RH Bugzilla Integration commented on JBRULES-3302:
--------------------------------------------------
lcarlon <lcarlon(a)redhat.com> made a comment on [bug
768952|https://bugzilla.redhat.com/show_bug.cgi?id=768952]
Technical note added. If any revisions are required, please edit the "Technical
Notes" field
accordingly. All revisions will be proofread by the Engineering Content Services
team.
New Contents:
When the 'in' keyword is used to evaluate a String value against a set of values
in the LHS of the rule, the String is treated as a float value. This was caused by a wrong
type coercion in MVEL. The issue has been resolved and String values are now treated as
Strings when used with the 'in' keyword.
Unwanted type coersion of String to float values when using
"in" keyword LHS
----------------------------------------------------------------------------
Key: JBRULES-3302
URL:
https://issues.jboss.org/browse/JBRULES-3302
Project: Drools
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: drools-compiler (expert)
Affects Versions: 5.2.0.Final, 5.3.0.Final
Environment: Windows 7, Rational Application Developer 7.5, Eclipse Helios
Service Release 2
Reporter: Troy Parrish
Assignee: Mario Fusco
Fix For: 5.4.0.Beta2
String values get treated as float values even when fact declares the property as a
String when using the "in" keyword to evaluate a String value against a set of
values in the lhs of the rule.
Example:
input into session : "10.5"
will match against all of the following values "10.5", "10.50",
"10.500" etc when in this format:
when
Fact(string in ("11.5", "10.50", "11.500"))
then
This problem behavior occurs in 5.3.0Final, 5.2.0.Final but not in 5.1.0Final, this is
when Expert went from using mvel 2.0.16 to mvel 2.1.0
Further information based on recent findings (12/02/2011)
When inserting a Fact with a Property that is an Object and the LHS references a property
of that object there is the unwanted type coercion even in 5.1.0Final
IE:
Class BigTest has two properties: Test and id. Test is an Object with a single property:
code.
If we reference in the LHS BigTest(test.code in (.....)) we get the unwanted coercion,
but when we reference BigTest(id in (.....)) the coercion does not occur. This is for
5.1.0Final. We find that the coercion takes place for both the syntax of BigTest(id in
(......)) and BigTest(test.code in (.....)) when using 5.2.0Final and up. Example code
below:
CLASSES:
public class BigTest {
private Test test;
private String id;
getters and setters .....
public class Test {
private String code;
getters and setters .....
DRL:
rule "Test.Code One"
when
BigTest($code : test.code in ("1.50", "2.50"))
then
System.out.println("Code compared values: 1.50, 2.50 - actual code value:
" + $code);
end
rule "Test.Code Two"
when
BigTest($code : test.code in ("1.5", "2.5"))
then
System.out.println("Code compared values: 1.5, 2.5 - actual code value:
" + $code);
end
rule "Big Test ID One"
when
BigTest($id : id in ("3.5", "4.5"))
then
System.out.println("ID compared values: 3.5, 4.5 - actual ID value: " +
$id);
end
rule "Big Test ID Two"
when
BigTest($id : id in ( "3.0", "4.0"))
then
System.out.println("ID compared values: 3.0, 4.0 - actual ID value: " +
$id);
end
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see:
http://www.atlassian.com/software/jira