[rules-users] Error in MVEL execution (optimization?)

ronalbury ronalbury at gmail.com
Wed Jan 4 19:07:41 EST 2012


I hardly got any viewers (and no responses) when I posted this just as "MVEL
Optimization" ... so I have changed the subject and re-posted (my apologies
if I just broke protocol).


I'm not sure how to explain this, other than it appears that MVEL is trying
to optimize the When conditions in my rules.   

I have a utility class, Test, with a number of methods on it (including null
protected versions of Drools "in" and "matches").  Note that the valueInList
method can return null (e.g. if the product code is null), and the
getAgeAsInt method can also return null (if the age is null).  I don't like
having to test if the result of the method is true, but I kept running into
null pointer errors in the Drools expression evaluation code and had to
adopt this convention. 

Here are two example rules (one in Java dialect and one in MVEL dialect).  I
realize that a list of one is a degenerate case for using 'inList', but it
should still work. 

rule "Term 15Plus Max Age - Washington" 
        dialect "java" 
        when 
                $ea : EasyApp( 
                        Test.valueInList($ea.getEaProductCode(),
"L15P")==true 
                    && Test.valueInList($ea.getEaIssueState(), "WA")==true 
                    && $ea.getPriIns_xmPerson().getAgeAsInt() > 65 
                    ) 
        then 
                $ea.addError(drools.getRule().getName()); 
end 

rule "Term 20 Max Age - New Jersey" 
        when 
                $ea : EasyApp( 
                        Test.valueInList(eaProductCode, "L20")==true 
                    && Test.valueInList(eaIssueState, "NJ")==true 
                    && priIns_xmPerson.ageAsInt > 64 
                    )	             
        then 
                $ea.addError(drools.getRule().getName()); 
end 

I have approximately 30 different rules similar to those above.  When I have
the rules written in MVEL, it appears to be only be evaluating one rule per
EasyApp injection (I have a log message when ever valueInList is called),
and I get bogus results.  However, when I shift to java dialect then it
appears that the methods are called for each rule I have defined (as I would
have expected). 

Can anyone tell me if I am doing something wrong, and explain why Drools is
behaving as it is? 

Thanks

--
View this message in context: http://drools.46999.n3.nabble.com/Error-in-MVEL-execution-optimization-tp3633440p3633440.html
Sent from the Drools: User forum mailing list archive at Nabble.com.



More information about the rules-users mailing list