[
https://jira.jboss.org/browse/JBRULES-2257?page=com.atlassian.jira.plugin...
]
Michael Paitl commented on JBRULES-2257:
----------------------------------------
I have a following rule which worked as expected in version 4(4.0.3) but is not working in
version 5 (5.0.1 or 5.1.0-SNAPSHOT):
rule "Test rule"
when
Message($var1:prop1 matches "^[6,7,9]$" , $var2:prop2 matches
"^[1]$" || $var3:prop3 matches "^[1]$", $var4:prop4 not matches
"^(.{0})$" )
then
System.out.println( "Message is not displayed for prop1='6' ,
prop2='', prop3='', prop4='1' in v4 but is in v5" );
end
However, if i remove variable assignment from either prop2 or prop3 e.g.
rule "Test rule"
when
Message($var1:prop1 matches "^[6,7,9]$" , prop2 matches "^[1]$" ||
$var3:prop3 matches "^[1]$", $var4:prop4 not matches "^(.{0})$" )
then
System.out.println( "Message is not displayed for prop1='6' ,
prop2='', prop3='', prop4='1' in both v4 and v5 " );
end
then both V4 and V5 will not display the message
Wrong condition evaluation if the condition contains a variable
assignment
----------------------------------------------------------------------------
Key: JBRULES-2257
URL:
https://jira.jboss.org/browse/JBRULES-2257
Project: Drools
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: drools-core
Affects Versions: 5.0.1.FINAL
Environment: Mac OS X, iMac, Eclipse Galileo (3.5)
Reporter: Udo Klinkmüller
Assignee: Edson Tirelli
Fix For: 5.1.0.FINAL
I have a rule which checks variables of two equal objects in an old and a new version. If
I work with the variable daclaration $nd1 then the consequence is NOT executed although it
should.
This is the version of the rule in that the consequence is not executed although it
should:
------------------------------------------
package apm.event.resource;
#list any import classes here.
import java.util.*;
import de.fraport.test.*;
#declare any global variables here
global Collection results;
rule "Test-Del"
salience 900
when
#conditions
TestMainObjectPair( $omo: oldMainObject != null, $nmo: newMainObject )
TestObject( date1 == null, $od2: date2 != null, $os1: strVal1 != null ) from
$omo.testObject
TestObject( $nd1: date1 != null || date2 != $od2 || strVal1 != $os1 ) from
$nmo.testObject
then
#actions
System.out.println("****** Executing consequence of rule Test-Del nd1="+ $nd1
+" ...");
results.add($nto);
end
------------------------------------------
This is the rule version which delivers the expected result (without using $nd1):
------------------------------------------
package apm.event.resource;
#list any import classes here.
import java.util.*;
import de.fraport.test.*;
#declare any global variables here
global Collection results;
rule "Test-Del"
salience 900
when
#conditions
TestMainObjectPair( $omo: oldMainObject != null, $nmo: newMainObject )
TestObject( date1 == null, $od2: date2 != null, $os1: strVal1 != null ) from
$omo.testObject
$nto: TestObject( date1 != null || date2 != $od2 || strVal1 != $os1 ) from
$nmo.testObject
then
#actions
System.out.println("****** Executing consequence of rule Test-Del nd1="+
$nto.getDate1() +" ...");
results.add($nto);
end
------------------------------------------
If wished, I have a corresponding JUnit test case for this issue.
--
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