[rules-users] possible bug in latest SNAPSHOT -AccumulateFunction.init() is called when calling modify()

Swindells, Thomas TSwindells at nds.com
Wed May 12 11:24:23 EDT 2010


Why is it an issue?

Your rule modifies holder so that the accumulate is no longer needed for that particular holder, presumably init is called so that the accumulator can restart its state from scratch and so release the memory it no longer needs.  I don't know if it does but this would then mean the accumulator could be reused later.

I'm not sure how collectList works (or holder.setList) but I'd imagine there should probably be a clone in there somewhere - having it within holder.setList would generally be the most appropriate and correct way to ensure the list doesn't get changed from underneath the holders nose.

Thomas

From: rules-users-bounces at lists.jboss.org [mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Michal Bali
Sent: 12 May 2010 15:09
To: Rules Users List
Subject: Re: [rules-users] possible bug in latest SNAPSHOT -AccumulateFunction.init() is called when calling modify()

You're probably right.

I have modified the last rule:
----------------------------
rule "GoodBye"
no-loop true
          when
                      $holder : Holder( )
                ...
-------------------------------
and it now works as expected.

However, this is still an issue...

Best regards,
Michal

On Wed, May 12, 2010 at 2:25 PM, Salaboy <salaboy at gmail.com<mailto:salaboy at gmail.com>> wrote:
Could be that the modify make the rule condition to be no longer true,
and for that reason the acumulation is zero in that point? I would
like to try it but I'm in my cell phone.

- Ing. Mauricio Salatino -

On May 12, 2010, at 6:58, Michal Bali <michalbali at gmail.com<mailto:michalbali at gmail.com>> wrote:

> Hi,
>
> I may have found a bug with accumulate and 'modify(..)' 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:
>
> I am using the latest snapshot of Drools 5.1.SNAPSHOT
>
> I have created a sample Drools project and just modified the
> Sample.drl with this:
> -------------------------------------------------------------
> import java.util.List;
> import java.util.ArrayList;
>
> declare Holder
>   list : List
> end
>
> rule "Hello World"
>       when
>               m : Message( )
>       then
>               insert(new Holder());
> end
>
> rule "GoodBye"
>       when
>               $holder : Holder( list == null )
>               $messages : List() from accumulate(
>                       $message: Message(), collectList($message) )
>       then
>               System.out.println($messages); //<-- here the $messages list has
> one element
>               modify($holder) {
>                       setList($messages)
>               }
>               System.out.println($messages); //<-- here the $messages list is
> empty
> end
> -----------------------------------------------------
>
> Let me know if you need more information. I can create a JIRA if
> needed.
>
> Thank you!
> Best regards,
> Michal
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org<mailto:rules-users at lists.jboss.org>
> https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users at lists.jboss.org<mailto:rules-users at lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/rules-users


________________________________

**************************************************************************************
This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmaster at nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary.

NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00
**************************************************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20100512/7137bf51/attachment.html 


More information about the rules-users mailing list