By the way, while checking into various scenarios prompted by Wolfgang's response, I came up with a very interesting test program:
rule "Initialize" salience 100 when eval(true) then insert("one"); insert(new String("one")); insertLogical("two"); insertLogical(new String("two")); end rule "Find strings" salience 50 when $s : String() then System.out.println("I found string: " + $s); end rule "Gather strings" salience 50 when accumulate( $s : String(), $sSet : collectSet( $s ), $sList : collectList( $s ) ) then System.out.println("Here is the set of all strings: " + $sSet); System.out.println("Here is the list of all strings: " + $sList); end What would you expect that to output? How many "I found string: xxx" lines would there be? How many entries in the "set of all strings"? How many entries in the "list of all strings"? For my part, I figured there would be four "I found string: xxx" lines, two entries in the set, and four entries in the list. I was very surprised to find the following output: I found string: two I found string: one I found string: one Here is the set of all strings: [two, one] Here is the list of all strings: [one, one, two] This strongly suggests that "insert" objects are held in an identity-preserving structure, but that "insertLogical" objects are held in an equals()-based structure. I am glad for the identity-based handling of "insert" objects, especially considering that all of my inserted objects come from "outside" the engine. I would hate to see one of them fail to be considered by the rule engine. I can almost see some usefulness for the equals() behavior of insertLogical objects, but far more potential problems. I think it's slightly dangerous that these behaviors differ and that it is not, AFAIK, documented in a way that is clear to users of Drools. -- View this message in context: http://drools.46999.n3.nabble.com/BUG-5-3-0-Final-CollectSetAccumulateFunction-should-probably-use-IdentityHashMap-internally-tp3774079p3775619.html Sent from the Drools: Developer (committer) mailing list mailing list archive at Nabble.com. _______________________________________________ rules-dev mailing list rules-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-dev