[rules-users] NPE from LHS of rule is not returned by Drools to calling program

scottleff scott.leff at fbfs.com
Thu Mar 29 11:09:20 EDT 2012


Your example has openned my eyes to a few facts that ultimately allowed me to
find the cause.  You proved that swallowing the NPE from the LHS was indeed
not the default behavior for Drools.  Let me pecursor the rest of my
response with the fact this design was not mine, I was just asked to support
it.  To give some details on the true cause I need to disclose that the app
does not insert a Coverage fact into the KnowledgeSession before calling
fireAllRules, but rather a larger encompassing object called Policy.  In
order to get a Coverage fact into WorkingMemory the following rule is put
into an agendaGroup that is guaranteed to run before the rule I posted
initially:

rule "policyDefinition.Coverage"
agenda-group "policyDefinition"
	when
		$p : Policy()
		$cov : Coverage() from $p.coverageList
	then
	    try {
		    insert($cov);
	    }
		catch (Exception e) {
		    e.printStackTrace();
	    }
end

As you can see, it is this rule that is sending the RuntimeException to
System.err (in effect swallowing it).  Thank you for example.

--
View this message in context: http://drools.46999.n3.nabble.com/NPE-from-LHS-of-rule-is-not-returned-by-Drools-to-calling-program-tp3865110p3867990.html
Sent from the Drools: User forum mailing list archive at Nabble.com.



More information about the rules-users mailing list