I enhanced my ConsequenceExceptionHandler and have a little more detail on
this. I have this rule:
rule "Duplicate Alerts"
when
$firstAlert : TemperatureAlert( this.saved, this.valid )
$secondAlert : TemperatureAlert (this.location == $firstAlert.location,
this != $firstAlert, this.saved, this.valid )
then
LOG.info("Removing duplicate alert for " + $firstAlert.getLocation());
$secondAlert.setValid(false);
$secondAlert.setInvalidAt(new Date());
update($secondAlert);
end
The TemperatureAlert class is not defined as an event.
I'm getting this exception:
15:56:34,145 ERROR [STDERR] CONSEQUENCE EXCEPTION
15:56:34,145 ERROR [STDERR] Exception executing consequence for rule
"Duplicate Alerts" in xxx.xxxxxxx.rules: java.lang.NullPointerException
15:56:34,145 ERROR [STDERR] START FACT DUMP:
15:56:34,145 ERROR [STDERR]
$firstAlert:xxx.xxxxxxx.TemperatureAlert@1e3c1689
15:56:34,145 ERROR [STDERR] $secondAlert:null
15:56:34,145 ERROR [STDERR] END FACT DUMP
15:56:34,145 ERROR [STDERR] Exception executing consequence for rule
"Duplicate Alerts" in xxx.xxxxxxx.rules: java.lang.NullPointerException
I don't see how this activation could have ever happened.
If there never was an object that qualified, the activation would never have
been scheduled.
If there was one, but it was updated so it no longer matched or was
retracted, then the activation would have been cancelled.
Everything -- EVERYTHING -- for the session is done within a single thread:
Runnable r = new Runnable() {
public void run() {
while (!shuttingDown) {
try {
session.fireUntilHalt();
while (!commandList.isEmpty()) {
commandList.take().execute();
}
} catch (Throwable t) {
t.printStackTrace();
}
}
}
};
The "commandList" is a BlockingQueue of objects that, when execute() is
called, variously insert, retract, or update objects. All the data feeding
into the session flows through that queue. The halt() method is called
either when the queue gets too long and periodically if it's not empty.
Any ideas?
--
View this message in context:
http://drools.46999.n3.nabble.com/Rules-called-with-null-references-tp347...
Sent from the Drools: User forum mailing list archive at
Nabble.com.