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

collect-ing into a HashSet generates a List

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 8.44.0.Final
    • 8.43.0.Final
    • core engine
    • None
    • 2023 Week 33-35 (from Aug 14)
    • NEW
    • NEW
    • ---
    • ---

    Description

      I'm trying to collect into a non-list type as there may be duplicates which I'd like to filter out using the Set semantics. The documentation states:
      The result pattern of the collect element can be any concrete class that implements the java.util.Collection interface and provides a default no-arg public constructor. You can use Java collections like List, LinkedList, and HashSet, or your own class.

      So in my rules I'm using a HashSet:

      $alarms: HashSet() from collect(Alarm(status == "pending"))

      In the then clause of the rule I'm calling a Java helper method which expects a java.util.Set but compilation fails because my helper method does not accept java.util.List as parameter type.

      A reproducer can be found here: https://github.com/comlinegmbh/kogito-collect-error-poc

      Attachments

        Activity

          People

            mfusco@redhat.com Mario Fusco
            dirk.olmes Dirk Olmes (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: