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

Couldn't anymore personalize comparison method starting from drools 5.4.0

This issue belongs to an archived project. You can view it, but you can't modify it. Learn more

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • Major
    • None
    • 5.4.0.Final
    • drools-compiler
    • None
    • Compatibility/Configuration

    Description

      I can't write anymore (since 5.4.0) straightforward rules such as :

      rule "linux kernel too old"
      when
      s:LinuxServer(release < "2.6.18")
      then
      insert(new ConfWarning(s,
      "Linux kernel is too old "+s.name))
      end

      where release is using Release type with a dedicated comparator :

      case class Release(
      name:String
      ) extends Ordered[AnyRef] {
      override def compare(that:AnyRef) : Int = that match

      { case Release(thatname) => NaturalSort.ord.compare(name, thatname) case thatname:String => NaturalSort.ord.compare(name, thatname) case _ => 1 }

      }

      I got the following error with the latest drools (it was ok with previous releases) :
      [Error: Comparison operation requires compatible types. Found class com.orange.confxpert.model.Release and class java.lang.String]

      I know that type enforcing is very important, but we should have a way to choose how strict must be type enforcements.

      User experience is very important, saying release < "2.6.18" is quite more user friendly than saying release < Release.fromString("2.6.18"). This is an important issue, as rules may be written by non IT people.

      [info] Running com.orange.confxpert.Main -a -r -v examples/xxxx/yyyyy
      Unable to Analyse Expression release < "2.6.18":
      [Error: Comparison operation requires compatible types. Found class xxxxx.model.Release and class java.lang.String]
      [Near :

      {... release < "2.6.18" ....}

      ]
      ^ : [Rule name='linux kernel too old']

      [error] (run-main) java.lang.IllegalArgumentException: Could not parse knowledge.
      java.lang.IllegalArgumentException: Could not parse knowledge.
      at org.drools.builder.impl.KnowledgeBuilderImpl.newKnowledgeBase(KnowledgeBuilderImpl.java:73)
      at zzzzzz.Main$.analyze(Main.scala:66)
      at zzzzzz..Main$$anonfun$main$1.apply(Main.scala:98)
      at zzzzzz..Main$$anonfun$main$1.apply(Main.scala:96)
      at scala.Option.map(Option.scala:133)
      at zzzzzz..Main$.main(Main.scala:96)
      at zzzzzz..Main.main(Main.scala)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      java.lang.RuntimeException: Nonzero exit code: 1
      at scala.sys.package$.error(package.scala:27)

      Attachments

        Activity

          People

            mfusco@redhat.com Mario Fusco
            davcro Crosson David (Inactive)
            Archiver:
            rhn-support-ceverson Clark Everson

            Dates

              Created:
              Updated:
              Resolved:
              Archived:

              PagerDuty