<div>Hi,</div><div><br></div><div>I may have found a bug with accumulate and &#39;modify(..)&#39; function call. It seems that once the modify(..) is called it indirectly calls AccumulateFunction.init() which invalidates accumulated data. I have included a simple test case:</div>
<div><br></div><div>I am using the latest snapshot of Drools 5.1.SNAPSHOT</div><div><br></div><div>I have created a sample Drools project and just modified the Sample.drl with this:</div><div>-------------------------------------------------------------</div>
<div><div>import java.util.List;</div><div>import java.util.ArrayList;</div><div> </div><div>declare Holder</div><div>  list : List</div><div>end </div><div> </div><div>rule &quot;Hello World&quot;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>when</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>m : Message( )</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>then</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>insert(new Holder());</div>
<div>end</div><div><br></div><div>rule &quot;GoodBye&quot;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>when</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>$holder : Holder( list == null )</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>$messages : List() from accumulate(</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>$message: Message(), collectList($message) )</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>then</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>System.out.println($messages); //&lt;-- here the $messages list has one element</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>modify($holder) {</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>setList($messages)</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>System.out.println($messages); //&lt;-- here the $messages list is empty</div><div>end</div><div>-----------------------------------------------------</div>
<div><br></div><div>Let me know if you need more information. I can create a JIRA if needed.</div><div><br></div><div>Thank you!</div><div>Best regards,</div><div>Michal</div></div>