[rules-users] Trouble using java.util.List.size in constraints in 5.4.0.Final

Wolfgang Laun wolfgang.laun at gmail.com
Thu Jun 14 10:24:23 EDT 2012


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 at 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
>


More information about the rules-users mailing list