[jboss-jira] [JBoss JIRA] (DROOLS-107) NPE when inserting through rule (object already present as derived class)

Jean-Marc Vanel (JIRA) jira-events at lists.jboss.org
Fri Apr 26 08:06:54 EDT 2013


    [ https://issues.jboss.org/browse/DROOLS-107?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12770381#comment-12770381 ] 

Jean-Marc Vanel commented on DROOLS-107:
----------------------------------------

Sorry I forgot to tidy the dependencies in the test.
It is now done ( at the same URL's ).

And 5.5.1-SNAPSHOT has the same NPE.
                
> NPE when inserting through rule (object already present as derived class)
> -------------------------------------------------------------------------
>
>                 Key: DROOLS-107
>                 URL: https://issues.jboss.org/browse/DROOLS-107
>             Project: Drools
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>    Affects Versions: 5.5.0.Final
>         Environment: % java -version               
> java version "1.7.0_21"
> Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
> Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)
> % uname -a 
> Linux oem-laptop 3.5.0-28-generic #47-Ubuntu SMP Tue Apr 9 19:03:54 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
>            Reporter: Jean-Marc Vanel
>            Assignee: Mark Proctor
>
> NPE : unit test which depends only on 3 non Drools simple classes : Assignment, Triple, TripleUser
> unit test has 2 rules , 5 inserts, 3 fireAllRules : the last one makes the NPE.
> TestDroolsNPE.testRunRulesBefore
> testRunRulesBefore(eulergui.project.TestDroolsNPE)
> Exception executing consequence for rule "project-java-rules2.n3 0" in project_java_rules2_n3_1: java.lang.NullPointerException
> 	at org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
> 	at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1297)
> 	at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1221)
> 	at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1456)
> 	at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:710)
> 	at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:674)
> 	at org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:230)
> 	at eulergui.project.TestDroolsNPE.testRunRulesBefore(TestDroolsNPE.java:110)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:601)
> 	at junit.framework.TestCase.runTest(TestCase.java:176)
> 	at junit.framework.TestCase.runBare(TestCase.java:141)
> 	at junit.framework.TestResult$1.protect(TestResult.java:122)
> 	at junit.framework.TestResult.runProtected(TestResult.java:142)
> 	at junit.framework.TestResult.run(TestResult.java:125)
> 	at junit.framework.TestCase.run(TestCase.java:129)
> 	at junit.framework.TestSuite.runTest(TestSuite.java:255)
> 	at junit.framework.TestSuite.run(TestSuite.java:250)
> 	at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84)
> 	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
> 	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
> Caused by: java.lang.NullPointerException
> 	at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:196)
> 	at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:903)
> 	at org.drools.base.DefaultKnowledgeHelper.insertLogical(DefaultKnowledgeHelper.java:245)
> 	at org.drools.base.DefaultKnowledgeHelper.insertLogical(DefaultKnowledgeHelper.java:210)
> 	at org.drools.base.DefaultKnowledgeHelper.insertLogical(DefaultKnowledgeHelper.java:205)
> 	at project_java_rules2_n3_1.Rule_project_java_rules2_n3_0_dd5596b676034b1fb5b32877015997e3.defaultConsequence(Rule_project_java_rules2_n3_0_dd5596b676034b1fb5b32877015997e3.java:12)
> 	at project_java_rules2_n3_1.Rule_project_java_rules2_n3_0_dd5596b676034b1fb5b32877015997e3DefaultConsequenceInvokerGenerated.evaluate(Unknown Source)
> 	at project_java_rules2_n3_1.Rule_project_java_rules2_n3_0_dd5596b676034b1fb5b32877015997e3DefaultConsequenceInvoker.evaluate(Unknown Source)
> 	at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1287)
> 	... 25 more
> in class NamedEntryPoint :
>  
>     protected FactHandle insert(final Object object,
>                                 final Object tmsValue,
>                                 final boolean dynamic,
>                                 boolean logical,
>                                 final Rule rule,
>                                 final Activation activation) throws FactException {
>         if ( object == null ) {
>             // you cannot assert a null object
>             return null;
>         }
>  
>         try {
>             this.wm.startOperation();
>  
>             ObjectTypeConf typeConf = this.typeConfReg.getObjectTypeConf( this.entryPoint,
>                                                                           object );
>             if ( logical && !typeConf.isTMSEnabled()) {
>                 enableTMS(object, typeConf);
>             }
>  
>             InternalFactHandle handle = null;
>  
>             if ( this.wm.isSequential() ) {
>                 handle = createHandle( object,
>                                        typeConf );
>                 insert( handle,
>                         object,
>                         rule,
>                         activation,
>                         typeConf );
>                 return handle;
>             }
>             try {
>                 this.lock.lock();
>                 this.ruleBase.readLock();
>                 // check if the object already exists in the WM
>                 handle = this.objectStore.getHandleForObject( object );
>  
>                 if ( typeConf.isTMSEnabled() ) {
>                  
>                     EqualityKey key;
>  
>                     TruthMaintenanceSystem tms = wm.getTruthMaintenanceSystem();
>                     if ( handle == null ) {
>                         // lets see if the object is already logical asserted
>                         key = tms.get( object );
>                     } else {
>                         // Object is already asserted, so check and possibly correct its
>                         // status and then return the handle
>                         key = handle.getEqualityKey();
>  
>                         if ( key.getStatus() == EqualityKey.STATED ) {
>  
> // key == null here !!!!!!!!!!!!!!!!!!!
> //      conf.setAssertBehaviour( AssertBehaviour.EQUALITY );
>  
> when rule inserts Triple :
> <file:/home/jmv/src/eulergui-code/eulergui/test/import.n3p.n3> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Ontology> .
>  
> that is already present, as a TripleUser extends Triple, but equals() and hashCode() are the same ;
> this object is both asserted and inferred as a Triple object

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the jboss-jira mailing list