[jboss-jira] [JBoss JIRA] Created: (JBRULES-548) NPT when binding a variable and comparing that variable to another property of the same object the variable was bound from

ELCA SII (JIRA) jira-events at jboss.com
Thu Nov 9 04:54:41 EST 2006


NPT when binding a variable and comparing that variable to another property of the same object the variable was bound from 
---------------------------------------------------------------------------------------------------------------------------

                 Key: JBRULES-548
                 URL: http://jira.jboss.com/jira/browse/JBRULES-548
             Project: JBoss Rules
          Issue Type: Bug
      Security Level: Public (Everyone can see)
          Components: Reteoo
    Affects Versions: 3.0.4
         Environment: Windows 2000
Sun JDK 1.5.0_02
            Reporter: ELCA SII
         Assigned To: Mark Proctor
             Fix For: 3.0.5


I want to have a rule that compares one property of an object with another one of the same object.

Sample Object:
<snip>
public class TestDomainObject {
	public TestDomainObject() {
	}
	public Integer getValueX() {
		return new Integer(200);
	}
	public Integer getValueY() {
		return new Integer(300);
	}
}
</snip>

I have the following rule in NRL:
<snip>
rule "Rule2"
	when
		TestDomainObject( y : valueY, valueX < y )
	then
		System.out.println("valueX < valueY");
end
</snip>

or XML:
<snip>
  <rule name="rule2.B">
	<lhs>
		<column object-type="TestDomainObject" identifier="p2">
			<literal field-name="type" evaluator="==" value="invoice"/>
			<field-binding field-name="valueY" identifier="v1"/>
			<bound-variable field-name="valueX" evaluator="&lt;=" identifier="v1"/>
		</column>
	</lhs>
	<rhs>
 		System.out.println("rule 2.B valueX &lt;= valueY");
	</rhs>
  </rule>
</snip>

And this leads to the following exception (3.0.4 and 3.0.x branch head):
<snip>
java.lang.NullPointerException
	at org.drools.rule.BoundVariableConstraint.isAllowed(BoundVariableConstraint.java:79)
	at org.drools.common.BetaNodeBinder.isAllowed(BetaNodeBinder.java:63)
	at org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.java:142)
	at org.drools.reteoo.ObjectSource.propagateAssertObject(ObjectSource.java:119)
	at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:138)
	at org.drools.reteoo.ObjectSource.propagateAssertObject(ObjectSource.java:119)
	at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:158)
	at org.drools.reteoo.Rete.assertObject(Rete.java:120)
	at org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:180)
	at org.drools.reteoo.ReteooWorkingMemory.doAssertObject(ReteooWorkingMemory.java:69)
	at org.drools.common.AbstractWorkingMemory.assertObject(AbstractWorkingMemory.java:538)
	at org.drools.common.AbstractWorkingMemory.assertObject(AbstractWorkingMemory.java:374)
	...
</snip>

In the code at 
- org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.java:142)

the call
- this.binder.isAllowed( handle, null, workingMemory )
is made (in the case the binder is not null). For the second parameter (tuple), 'null' is passed explicitly.

later in the calling stack at:
- org.drools.rule.BoundVariableConstraint.isAllowed(BoundVariableConstraint.java:79)

the following call is made: 
- tuple.get(...)

=> But the for the 'tuple' 'null' was passed in beforehand

-- 
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