]
Edson Tirelli reassigned JBRULES-954:
-------------------------------------
Assignee: Edson Tirelli (was: Mark Proctor)
'==' & '!=' not working properly with globals
---------------------------------------------
Key: JBRULES-954
URL:
http://jira.jboss.com/jira/browse/JBRULES-954
Project: JBoss Rules
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: Drl Parser/Builder
Affects Versions: 4.0.0.MR3
Environment: Windows XP, Drools MR3
Reporter: Brian Enderle
Assigned To: Edson Tirelli
The equality operators (== & !=) are not working correctly when comparing a value to
a global. This holds true for globals of the type java.lang.Character, java.lang.String
and java.lang.Long (only ones I tested, but probably others as well).
Given:
Person object with sex set to 'M'
rule "Must be male"
when
$p : Person ( sex == 'M' )
then
System.out.println ( "- This is a man" );
end
rule "Cannot be a man"
when
$p : Person ( sex != 'M')
then
System.out.println ( "- This must be a woman")
end
Results:
- This is a man
If we replace the 'M' with the global "maleCode" and set it to
'M' in our calling program then,
gloabl java.lang.Character maleCode;
rule "Must be male"
when
$p : Person ( sex == maleCode )
then
System.out.println ( "- This is a man" );
end
rule "Cannot be a man"
when
$p : Person ( sex != maleCode)
then
System.out.println ( "- This must be a woman")
end
Results:
- This is a man
- This must be a woman
Both rules are passing when one, the latter, should fail
Brian Enderle
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: