Uploaded image for project: 'JBRULES'
  1. JBRULES
  2. JBRULES-548

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Duplicate Issue
    • Affects Version/s: 3.0.4
    • Fix Version/s: 3.0.5, 3.1-m1
    • Component/s: drools-core (expert)
    • Labels:
      None
    • Environment:

      Windows 2000
      Sun JDK 1.5.0_02

      Description

      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">
      <field-binding field-name="valueY" identifier="v1"/>
      <bound-variable field-name="valueX" evaluator="<=" identifier="v1"/>
      </column>
      </lhs>
      <rhs>
      System.out.println("rule 2.B valueX <= 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

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                mark.proctor Mark Proctor
                Reporter:
                elca-sumex2 ELCA SII
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: