Previously ALL collections where cloned when bound:
public Object getNonShadowedValue(InternalWorkingMemory workingMemory, final Object object) { Object result = this.readAccessor.getValue( workingMemory, object ); if ( this.isInternalFact() && result instanceof Collection ) { try { Collection newCol = (Collection) result.getClass().newInstance(); for ( Iterator it = ((Collection) result).iterator(); it.hasNext(); ) { Object element = it.next(); newCol.add( element ); } return newCol; } catch ( InstantiationException e ) { // nothing we can do, so just return the resulting object } catch ( IllegalAccessException e ) { // TODO Auto-generated catch block } } return result; }
This was left over from shadow facts and actually still existed today. I have removed the code but now we have a failing test in FirstOrderLogicTest.testCollectResultConstraints.
rule "Collect Test" salience 70
when
$cheeseList : ArrayList(size == 1) from collect( Cheese( ) );
then
results.add($cheeseList);
end
The reason why this passed before was the collection was
cloned, so the accumulate's evaulations would not impact it. Now
it is no longer cloned and while the rule does not fire the
Collection is updated. I think the later is the correct
behaviour and I've updated the test as expected. Everyone
agreed?