Regression. Rule misfires due to constraint list[0].field1/2 in two rules
-------------------------------------------------------------------------
Key: JBRULES-3130
URL:
https://issues.jboss.org/browse/JBRULES-3130
Project: Drools
Issue Type: Bug
Security Level: Public (Everyone can see)
Affects Versions: 5.2.0.Final
Reporter: Wolfgang Laun
Assignee: Mark Proctor
Priority: Critical
Fix For: 5.2.1.Final
A pair of constraints suich as list[0].a == null and list[0].b == null in two different
rules causes one of the rules not to fire and the other one to fire erroneously (see
results at the end).
Java:
================================================================
public class Three {
private String a;
private String b;
private String c;
public Three( String a, String b, String c ){
this.a = a;
this.b = b;
this.c = c;
}
public String getA(){ return a; }
public String getB(){ return b; }
public String getC(){ return c; }
}
================================================================
import java.util.*;
public class ListOfThree {
private List<Three> list;
private Class<?> clazz;
public ListOfThree( Three three, Class<?> clazz ){
list = new ArrayList<Three>();
list.add( three );
this.clazz = clazz;
}
public List<Three> getList(){ return list; }
public Class<?> getClazz(){ return clazz; }
}
================================================================
// Insertion of facts
Three three = new Three( "a", "b", "c" );
ListOfThree listof3 = new ListOfThree( three, java.lang.Object.class );
kSession.insert( listof3 );
three = new Three( "x", null, "z" );
listof3 = new ListOfThree( three, java.lang.String.class );
kSession.insert( listof3 );
three = new Three( null, "q", "r" );
listof3 = new ListOfThree( three, java.lang.Integer.class );
kSession.insert( listof3 );
===================================================================
rule 'rule1'
############################ dialect "mvel" ## does not matter
when
ListOfThree( list[0].a == null, $c: clazz );
then
System.out.println( "rule1 " + $c.getSimpleName() );
end
rule 'rule2'
############################ dialect "mvel" ## does not matter
when
ListOfThree( list[0].b == null, $c: clazz );
then
System.out.println( "rule2 " + $c.getSimpleName() );
end
=================================================================
Results:
rule2 Integer
rule1 Integer
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira