Hi Davide,

I've got a null pointer exception with defeasible. My test case is:

package com.sample

declare Fact
     fact: String @key
end

rule init
     when
     then
         System.out.println("inserting initial facts");
         insert( new Fact( "one" ) );
         insert( new Fact( "two" ) );
         insert( new Fact( "two" ) );
end

rule rule1
     @Defeasible
     enabled true
     when
         Fact( "one"; )
     then
         System.out.println("one causes wibble");
         insertLogical( new Fact( "wibble") );
end

rule rule2
     @Defeasible
     when
         Fact( "two"; )
     then
         System.out.println("two causes wibble");
         insertLogical( new Fact( "wibble") );
end

rule rule3
     @Defeater
     @Defeats( "rule2" )
     when
         Fact( "two"; )
     then
         System.out.println("two negates wibble");
         insertLogical( new Fact( "wibble"), "neg" );
end

The output I get is

inserting initial facts
one causes wibble
two causes wibble
two causes wibble
two negates wibble
two negates wibble
Exception executing consequence for rule "rule3" in com.sample: 
java.lang.NullPointerException
     at 
org.drools.core.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
     at 
org.drools.core.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1057)
     at org.drools.core.phreak.RuleExecutor.fire(RuleExecutor.java:152)
     at 
org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:94)
     at 
org.drools.core.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:964)
     at 
org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1234)
     at 
org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1239)
     at 
org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1212)
     at com.sample.DroolsTest.main(DroolsTest.java:21)
Caused by: java.lang.NullPointerException
     at 
org.drools.core.beliefsystem.defeasible.DefeasibleBeliefSet.removeUndefeated(DefeasibleBeliefSet.java:295)
     at 
org.drools.core.beliefsystem.defeasible.DefeasibleBeliefSet.add(DefeasibleBeliefSet.java:126)
     at 
org.drools.core.beliefsystem.jtms.JTMSBeliefSystem.insert(JTMSBeliefSystem.java:52)
     at 
org.drools.core.beliefsystem.defeasible.DefeasibleBeliefSystem.insert(DefeasibleBeliefSystem.java:45)
     at 
org.drools.core.common.TruthMaintenanceSystem.addLogicalDependency(TruthMaintenanceSystem.java:136)
     at 
org.drools.core.common.TruthMaintenanceSystem.addLogicalDependency(TruthMaintenanceSystem.java:107)
     at 
org.drools.core.common.NamedEntryPoint.insert(NamedEntryPoint.java:234)
     at 
org.drools.core.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:1430)
     at 
org.drools.core.base.DefaultKnowledgeHelper.insertLogical(DefaultKnowledgeHelper.java:275)
     at 
org.drools.core.base.DefaultKnowledgeHelper.insertLogical(DefaultKnowledgeHelper.java:247)
     at 
com.sample.Rule_rule32132126114.defaultConsequence(Rule_rule32132126114.java:8)
     at 
com.sample.Rule_rule32132126114DefaultConsequenceInvokerGenerated.evaluate(Unknown
 
Source)
     at 
com.sample.Rule_rule32132126114DefaultConsequenceInvoker.evaluate(Unknown 
Source)
     at 
org.drools.core.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1046)
     ... 7 more


I believe I am using snapshot 6.1.0.201407170510 but I suspect the 
precise version doesn't matter too much.

In the above example, if you disable rule1 then the NPE doesn't happen. 
Only doing one "two" fact insertion in the init rule likewise means the 
NPE doesn't happen. I think the issue is something like rule3 does more 
than one defeat on rule2's scoring on "wibble" fact, but rule1 still has 
a say in the continuing existence of the "wibble" fact.

Should I get a Jira log in and enter these well qualified bugs directly?

Regards,

Borris





_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to