[jboss-jira] [JBoss JIRA] (DROOLS-5271) RHS statements ordering changes with modify block in executable model

Toshiya Kobayashi (Jira) issues at jboss.org
Fri Apr 24 02:10:00 EDT 2020


     [ https://issues.redhat.com/browse/DROOLS-5271?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Toshiya Kobayashi updated DROOLS-5271:
--------------------------------------
    Description: 
The order of statements in RHS changes with executable model when modify block is involved. The below rule can tell the difference with standard-drl.
{noformat}
import org.drools.modelcompiler.domain.Person;global java.util.List list;
rule R when
  $p1 : Person(name == "John")
  $p2 : Person(name == "Paul")
then
  list.add($p1.getAge());
  list.add($p2.getAge());
  modify($p1) { setAge($p1.getAge()+1) }
  list.add($p1.getAge());
  list.add($p2.getAge());
  modify($p2) { setAge($p2.getAge()+5) }
  list.add($p1.getAge());
  list.add($p2.getAge());
end
{noformat}

{code:java}

{code}

  was:
The order of statements in RHS changes with executable model when modify block is involved. The below rule can tell the difference with standard-drl.
{noformat}
import org.drools.modelcompiler.domain.Person;global java.util.List list;
rule R when
  $p1 : Person(name == "John")
  $p2 : Person(name == "Paul")
then
  list.add($p1.getAge());
  list.add($p2.getAge());
  modify($p1) { setAge($p1.getAge()+1) }
  list.add($p1.getAge());
  list.add($p2.getAge());
  modify($p2) { setAge($p2.getAge()+5) }
  list.add($p1.getAge());
  list.add($p2.getAge());
end
{noformat}

{code:java}
                                                       D.on(var_$p1,
                                                            var_$p2,
                                                            var_list).execute((org.drools.model.Drools drools, org.drools.modelcompiler.domain.Person $p1, org.drools.modelcompiler.domain.Person $p2, java.util.List list) -> {
                                                           {
                                                               {
                                                                   list.add($p1.getAge());
                                                                   list.add($p2.getAge());
                                                                   list.add($p1.getAge());
                                                                   list.add($p2.getAge());
                                                                   list.add($p1.getAge());
                                                                   list.add($p2.getAge());
                                                                   ($p1).setAge($p1.getAge() + 1);
                                                                   drools.update($p1,
                                                                                 mask_$p1);
                                                                   ($p2).setAge($p2.getAge() + 5);
                                                                   drools.update($p2,
                                                                                 mask_$p2);
                                                               }
                                                           }
                                                       }));
{code}



> RHS statements ordering changes with modify block in executable model
> ---------------------------------------------------------------------
>
>                 Key: DROOLS-5271
>                 URL: https://issues.redhat.com/browse/DROOLS-5271
>             Project: Drools
>          Issue Type: Bug
>          Components: executable model
>    Affects Versions: 7.36.0.Final
>            Reporter: Toshiya Kobayashi
>            Assignee: Toshiya Kobayashi
>            Priority: Major
>
> The order of statements in RHS changes with executable model when modify block is involved. The below rule can tell the difference with standard-drl.
> {noformat}
> import org.drools.modelcompiler.domain.Person;global java.util.List list;
> rule R when
>   $p1 : Person(name == "John")
>   $p2 : Person(name == "Paul")
> then
>   list.add($p1.getAge());
>   list.add($p2.getAge());
>   modify($p1) { setAge($p1.getAge()+1) }
>   list.add($p1.getAge());
>   list.add($p2.getAge());
>   modify($p2) { setAge($p2.getAge()+5) }
>   list.add($p1.getAge());
>   list.add($p2.getAge());
> end
> {noformat}
> {code:java}
> {code}



--
This message was sent by Atlassian Jira
(v7.13.8#713008)


More information about the jboss-jira mailing list