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

DMN SortFunction throws java.lang.IllegalArgumentException: Comparison method violates its general contract!

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • 7.73.0.Final
    • dmn engine
    • None
    • Hide

      On openjdk version "11.0.20.1"

      This list will not cause SortFunction to fail: [110, 114, 110, 110, 112, 110, 110, 114, 112, 110, 110, 110, 110, 114, 114, 114, 112, 114, 114, 114, 112, 114, 114, 110, 110, 110, 110, 112, 110, 110, 114, 112, 110, 112, 112, 114, 110]

      This list will cause SortFunction to return a FEEL ERROR: [110, 110, 114, 110, 110, 112, 110, 110, 114, 112, 110, 110, 110, 110, 114, 114, 114, 112, 114, 112, 114, 114, 112, 114, 114, 110, 110, 110, 110, 112, 110, 110, 112, 114, 110, 112, 110, 112, 112, 112, 114, 110]

      Show
      On openjdk version "11.0.20.1" This list will not cause SortFunction to fail: [110, 114, 110, 110, 112, 110, 110, 114, 112, 110, 110, 110, 110, 114, 114, 114, 112, 114, 114, 114, 112, 114, 114, 110, 110, 110, 110, 112, 110, 110, 114, 112, 110, 112, 112, 114, 110] This list will cause SortFunction to return a FEEL ERROR: [110, 110, 114, 110, 110, 112, 110, 110, 114, 112, 110, 110, 110, 110, 114, 114, 114, 112, 114, 112, 114, 114, 112, 114, 114, 110, 110, 110, 110, 112, 110, 110, 112, 114, 110, 112, 110, 112, 112, 112, 114, 110]
    • Hide

      Omitting the "precedes" parameter makes the function use natural ordering. This workaround could not be used for reverse ordering or more complex ordering.

      Show
      Omitting the "precedes" parameter makes the function use natural ordering. This workaround could not be used for reverse ordering or more complex ordering.
    • NEW
    • NEW
    • ---
    • ---

      SortFunction returns FEEL ERROR while evaluating literal expression 'sort(myList,function(x,y) x < y)': The parameter 'list', in function sort(), raised an exception while sorting by natural order.

      The Throwable that is catched in invoke method is java.lang.IllegalArgumentException: Comparison method violates its general contract!

      Comparator built in org.kie.dmn.feel.runtime.functions.SortFunction.invoke(ctx,list,function) returns explicitely -1 or 1 but never 0. This violates the Comparable contract as stated here by Oracle for Java 7 and after.

       

            tzimanyi@redhat.com Tibor Zimányi
            david.b.cloutier David Cloutier (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: