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

Unary negation of a variable doesn't work right in an expression

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Minor
    • 6.0.0.CR1
    • 5.5.0.Final
    • None
    • None

    Description

      Consider this rule:

      <code>
      rule "Hitpoints.Lethal.Dead"
      when
      Stat(name == StatInput.CON, $con:value)
      CurrentHitpoints(type == "Lethal", value <= -$con)
      then
      insertLogical(new Condition(ConditionInput.TYPE_DEAD));
      end
      </code>

      This emits the following exception:

      <code>
      Exception in thread "Thread-2" java.lang.RuntimeException: Null accessor on node: $con
      at org.drools.rule.constraint.ConditionAnalyzer.analyzeNode(ConditionAnalyzer.java:247)
      at org.drools.rule.constraint.ConditionAnalyzer.analyzeSingleCondition(ConditionAnalyzer.java:108)
      at org.drools.rule.constraint.ConditionAnalyzer.analyzeCondition(ConditionAnalyzer.java:99)
      at org.drools.rule.constraint.ConditionAnalyzer.analyzeCondition(ConditionAnalyzer.java:70)
      at org.drools.rule.constraint.MvelConditionEvaluator.getAnalyzedCondition(MvelConditionEvaluator.java:83)
      at org.drools.rule.constraint.MvelConstraint.executeJitting(MvelConstraint.java:270)
      at org.drools.rule.constraint.MvelConstraint.access$200(MvelConstraint.java:51)
      at org.drools.rule.constraint.MvelConstraint$ConditionJitter.run(MvelConstraint.java:250)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
      at java.lang.Thread.run(Thread.java:680)
      </code>

      If I change the comparison to "value <= (0-$con)" then it works as expected.

      Attachments

        Activity

          People

            mfusco@redhat.com Mario Fusco
            chrisdolan_jira Chris Dolan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: