<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  </head>
  <body text="#000000" bgcolor="#ffffff">
    <a class="moz-txt-link-freetext" href="https://issues.jboss.org/browse/JBRULES-3051">https://issues.jboss.org/browse/JBRULES-3051</a><br>
    <div class="action-body flooded">
      <p>Previously ALL collections where cloned when bound:</p>
      <div class="code panel" style="border-width: 1px;">
        <div class="codeContent panelContent">
          <pre class="code-java"><span class="code-keyword">public</span> <span class="code-object">Object</span> getNonShadowedValue(InternalWorkingMemory workingMemory,
                                      <span class="code-keyword">final</span> <span class="code-object">Object</span> object) {
        <span class="code-object">Object</span> result = <span class="code-keyword">this</span>.readAccessor.getValue( workingMemory,
                                                    object );
        <span class="code-keyword">if</span> ( <span class="code-keyword">this</span>.isInternalFact() &amp;&amp; result <span class="code-keyword">instanceof</span> Collection ) {
            <span class="code-keyword">try</span> {
                Collection newCol = (Collection) result.getClass().newInstance();
                <span class="code-keyword">for</span> ( Iterator it = ((Collection) result).iterator(); it.hasNext(); ) {
                    <span class="code-object">Object</span> element = it.next();
                    newCol.add( element );
                }
                <span class="code-keyword">return</span> newCol;
            } <span class="code-keyword">catch</span> ( InstantiationException e ) {
                <span class="code-comment">// nothing we can <span class="code-keyword">do</span>, so just <span class="code-keyword">return</span> the resulting object
</span>            } <span class="code-keyword">catch</span> ( IllegalAccessException e ) {
                <span class="code-comment">// TODO Auto-generated <span class="code-keyword">catch</span> block
</span>            }
        }
        <span class="code-keyword">return</span> result;
    }</pre>
        </div>
      </div>
      <p>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.</p>
      <div class="code panel" style="border-width: 1px;">
        <div class="codeContent panelContent">
          <pre class="code-java">rule <span class="code-quote">"Collect Test"</span> salience 70
    when
        $cheeseList  : ArrayList(size == 1) from collect( Cheese( ) );
    then
        results.add($cheeseList);
end</pre>
        </div>
      </div>
      <p>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?<br>
      </p>
    </div>
    <br>
  </body>
</html>