Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-7653

Drools null pointer shows up when executing rules with exists() clauses.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • None
    • 7.68.0.Final, 8.44.0.Final, 9.43.0.Alpha
    • None
    • None
    • Hide

      I can reproduce this issue with the following drl:

       

      rule "Rule 1"
      no-loop true
          when
              $outputField: TextField(getName()=="outputField")
              
              TextField(getName()=="field1" && getValue() == "A")
              
              exists(
                  TextField(getName()=="field3" && getValue() == "1")
                  && TextField(getName()=="field2" && getValue() == "20")
              )
          then
          end
      rule "Rule 2"
      no-loop true
          when
              $outputField: TextField(getName()=="outputField")
              
              exists(
                  TextField(getName()=="field1" && getValue() == "A")
                  && TextField(getName()=="field3" && getValue() == "1")
                  && TextField(getName()=="field2" && getValue() == "20")
              )
          then
          end

      Sticking the needed fields into the session and running rules will immediately trigger this rule.  I have this setup in the attached DroolsPeerNullError.zip file.  Extract and run the main method and the error will be triggered.

      Changing almost anything about the conditions stops the error from happening so it is tied closely to exactly what has been put in this test.

       

      Show
      I can reproduce this issue with the following drl:   rule "Rule 1" no-loop true     when         $outputField: TextField(getName()== "outputField" )                  TextField(getName()== "field1" && getValue() == "A" )                  exists(             TextField(getName()== "field3" && getValue() == "1" )             && TextField(getName()== "field2" && getValue() == "20" )         )     then     end rule "Rule 2" no-loop true     when         $outputField: TextField(getName()== "outputField" )                  exists(             TextField(getName()== "field1" && getValue() == "A" )             && TextField(getName()== "field3" && getValue() == "1" )             && TextField(getName()== "field2" && getValue() == "20" )         )     then     end Sticking the needed fields into the session and running rules will immediately trigger this rule.  I have this setup in the attached DroolsPeerNullError.zip file.  Extract and run the main method and the error will be triggered. Changing almost anything about the conditions stops the error from happening so it is tied closely to exactly what has been put in this test.  
    • NEW
    • NEW
    • ---
    • ---

      Very complex conditions are triggering an error that shows up like:

      java.lang.NullPointerException: Cannot invoke "org.drools.core.reteoo.LeftTuple.getTupleSink()" because "lt" is null{}

      I have reduced the complexity to 2 rules with similar conditions that differ where a fact finds itself with respect to an exists() call.  The null "lt" is coming from a search through peers on a child of an ExistsNode.  One of the tuples that get created and associated to this node do not point to the correct node and we run out of links when searching peers.  This happens in the BetaNode.getStartTuple() method.  Either the nodes or the tuples are not getting constructed correctly.

              rhn-support-tkobayas Toshiya Kobayashi
              jeff@logik.io Jeffrey Wilkins (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: