[jboss-jira] [JBoss JIRA] Commented: (JBRULES-1264) NPE at BaseObjectClassFieldExtractor.getLongValue with null fields

Mark Proctor (JIRA) jira-events at lists.jboss.org
Wed Oct 10 12:55:06 EDT 2007


    [ http://jira.jboss.com/jira/browse/JBRULES-1264?page=comments#action_12381479 ] 
            
Mark Proctor commented on JBRULES-1264:
---------------------------------------

To summarise this is a bug on CompositeObjectSink - which is only used when you have 3+ == constraints on the same field, the 3 value can be overriden by the threshold configuration value. The indexing for CompositeObjectSink is not able to handle null values. The work around for this at the moment is to set alphaNodeHashingThreshold to 0.

> NPE at BaseObjectClassFieldExtractor.getLongValue with null fields
> ------------------------------------------------------------------
>
>                 Key: JBRULES-1264
>                 URL: http://jira.jboss.com/jira/browse/JBRULES-1264
>             Project: JBoss Drools
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>    Affects Versions: 4.0.2
>            Reporter: Alexandre Gattiker
>         Assigned To: Mark Proctor
>
> Removing one of the three rules magically solves the problem.
> java.lang.NullPointerException
> 	at org.drools.base.extractors.BaseObjectClassFieldExtractor.getLongValue(BaseObjectClassFieldExtractor.java:106)
> 	at org.drools.base.ClassFieldExtractor.getLongValue(ClassFieldExtractor.java:203)
> 	at org.drools.reteoo.CompositeObjectSinkAdapter$HashKey.setValue(CompositeObjectSinkAdapter.java:467)
> 	at org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:292)
> 	at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:153)
> 	at org.drools.reteoo.Rete.assertObject(Rete.java:177)
> 	at org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:201)
> 	at org.drools.reteoo.ReteooWorkingMemory.doInsert(ReteooWorkingMemory.java:71)
> 	at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:886)
> 	at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:858)
> 	at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:659)
> 	at com.sample.DroolsTest.main(DroolsTest.java:21)
> package com.sample;
> import java.io.InputStreamReader;
> import java.io.Reader;
> import org.drools.RuleBase;
> import org.drools.RuleBaseFactory;
> import org.drools.WorkingMemory;
> import org.drools.compiler.PackageBuilder;
> import org.drools.rule.Package;
> public class DroolsTest
> {
>     public static final void main(String[] args)
>     {
>         try
>         {
>             RuleBase ruleBase = readRule();
>             WorkingMemory workingMemory = ruleBase.newStatefulSession();
>             workingMemory.insert(new Attribute());
>             workingMemory.insert(new Message());
>             workingMemory.fireAllRules();
>         }
>         catch (Throwable t)
>         {
>             t.printStackTrace();
>         }
>     }
>     private static RuleBase readRule() throws Exception
>     {
>         Reader source = new InputStreamReader(DroolsTest.class.getResourceAsStream("/Sample.drl"));
>         PackageBuilder builder = new PackageBuilder();
>         builder.addPackageFromDrl(source);
>         Package pkg = builder.getPackage();
>         RuleBase ruleBase = RuleBaseFactory.newRuleBase();
>         ruleBase.addPackage(pkg);
>         return ruleBase;
>     }
>     public static class Message
>     {
>         //empty
>     }
>     public static class Attribute
>     {
>         public Integer getValue()
>         {
>             return null;
>         }
>     }
> }
> package com.sample
>  
> import com.sample.DroolsTest.Message;
> import com.sample.DroolsTest.Attribute;
>  
> rule "rule_1"
> 	
> 	when
> 		Message()
> 		Attribute(value == 1)
> 	then
> 		System.err.println("case 1");
> end
> rule "rule_2"
> 	
> 	when
> 		Message()
> 		Attribute(value == 2)
> 	then
> 		System.err.println("case 2");
> end
> rule "rule_3"
> 	
> 	when
> 		Message()
> 		$a:Attribute(value == 3)
> 	then
> 		System.err.println("case 3");
> end

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list