This looks like a bug.
MyObject( param.size > 0 ) => incorrect diagnostic
But:
MyObject( param.size() > 0 ) =>OK
MyObject( param.size == 0 ) =>OK
MyObject( param.size != 0 ) =>OK
-W
On 14/06/2012, Alexis Brouard <alexis.brouard(a)haulogy.net> wrote:
Hi everyone,
I've tried to go from Drools 5.3.0.Final to 5.4.0.Final and some strange
errors appeared on constraints using the size of a list.
For instance, given the following object:
public class MyObject {
private List<String> param = new ArrayList<String>();
public MyObject() {
super();
}
public List<String> getParam() {
return param;
}
public void setParam(List<String> param) {
this.param = param;
}
}
This rule:
rule "Sample rule"
when
MyObject( param.size > 0 )
then
System.out.println( "Sample rule activated" );
end
Provokes the following error:
Unable to Analyse Expression param.size > 0:
[Error: Comparison operation requires compatible types. Found class
java.lang.String and class java.lang.Integer]
[Near : {... param.size > 0 ....}]
^ : [Rule name='Sample rule']
This worked very well in Drools 5.3.0.Final.
Is there some configuration specific to Drools 5.4.0.Final that I've missed
in the release notes?
Thanks in advance for your help.
Best,
Alexis