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

NPE if rule checks a Long field for null, and a fact is passed in with Long field that is NOT null.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 4.0.4
    • Fix Version/s: 4.0.5, 5.0.0.M1
    • Component/s: None
    • Labels:
      None
    • Environment:

      os x, jdk 1.5

    • Workaround Description:
      Hide

      use eval(fieldValue == null)

      Show
      use eval(fieldValue == null)
    • Estimated Difficulty:
      Low

      Description

      If you have a fact class that has a field that is a Long:

      class MyFact {
      Long myField = new Long(0);
      ...
      }

      rule CheckMyField
      when
      MyFact(myField == null)
      then
      ... do something about it ...
      end

      If you pass that fact into the engine you will get an NPE. The problem lies in the fact that when comparing a Long against null, it thinks that since the value passed in is not null and is a Long, the second value should also be not null. But since the rule says to check for null, it fails trying to throw a ClassCastException. Since the second value is null, it gets an NPE trying to generate the message saying that value (null) is not of class Long.

      The problem is in org.drools.base.evaluators.ObjectFactory.ObjectEqualsComparator line 553. When arg0 is a Number it doesn't account for the possibility that arg1 might be null.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  tirelli Edson Tirelli
                  Reporter:
                  amccarri Alex McCarrier
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  1 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: