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

ClassCastException using dynamic salience

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 4.0.1
    • Fix Version/s: 4.0.2
    • Component/s: None
    • Labels:
      None

      Description

      I have the following dynamic salience:

      salience ( -10000 / (c.size * t.size) )

      that throws a ClassCastException when c.size * t.size is an odd number:

      java.lang.ClassCastException: java.lang.Double
      at org.drools.base.mvel.MVELSalienceExpression.getValue(MVELSalienceExpression.java:33)

      I then tried:

      salience ( (int)-10000 / (c.size * t.size) )

      or

      salience ( (int)( -10000 / (c.size * t.size) ))

      But got a MVEL error compiling the expression.

      The solution I found was to use a function:

      salience ( -1 * FN.priority(c.size, t.size) )

      Note that I had to use "1 *" because just "" gives me a MVEL error compiling the expression.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                mark.proctor Mark Proctor
                Reporter:
                ydewit Yuri de Wit
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: