[rules-users] Trouble using || operator and after evaluator in constraints in 5.4.0.Final

abr alexis.brouard at haulogy.net
Thu Aug 16 08:08:44 EDT 2012


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 after evaluator and the ||
operator.

For instance, considering these 2 objects :

public class MyObject {

	private Date myDate;

	public MyObject(Date myDate) {
		super();
		this.myDate = myDate;
	}

	public Date getMyDate() {
		return myDate;
	}

	public void setMyDate(Date myDate) {
		this.myDate = myDate;
	}
	
}

public class MyObjectList {

	private List<MyObject> myObjectList;

	public MyObjectList() {
		super();
		this.myObjectList = new ArrayList<MyObject>();
	}

	public List<MyObject> getMyObjectList() {
		return myObjectList;
	}

	public void setMyObjectList(List<MyObject> myObjectList) {
		this.myObjectList = myObjectList;
	}
	
	public void addObject(MyObject myObject) {
		this.myObjectList.add(myObject);
	}
	
}


This rule:

rule "Sample rule"
    when
    	CurrentDate( $now: now )
        $list: MyObjectList()
        $obj: MyObject(
        		this memberOf $list,
        		( myDate == null ||
        		  myDate after[ 5d ] $now ) )
    then
        System.out.println( "Sample rule activated" );
end


Provokes the following error:

Unable to Analyse Expression $list contains this && ( myDate == null ||
after0.evaluate( myDate, $now ) ):
[Error: unable to resolve method using strict-mode:
com.sample.MyObject.after0()]
[Near : {... ( myDate == null || after0.evaluate( myDate, $now ....}]
             ^ : [Rule name='Sample rule']


This worked very well in Drools 5.3.0.Final.

The strangest thing about this issue is that, if I change the || into a &&,
compilation works correctly!

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




--
View this message in context: http://drools.46999.n3.nabble.com/Trouble-using-operator-and-after-evaluator-in-constraints-in-5-4-0-Final-tp4019181.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list