[jboss-jira] [JBoss JIRA] (DROOLS-5237) Wrong property reactivity with non getter chain of argume
Toshiya Kobayashi (Jira)
issues at jboss.org
Wed Apr 15 23:00:47 EDT 2020
[ https://issues.redhat.com/browse/DROOLS-5237?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Toshiya Kobayashi updated DROOLS-5237:
--------------------------------------
Description:
DROOLS-5025 solves a case like this by exclude getter property from property reactivity mask.
{noformat}
rule R1 when
$p : Person( name == "Mario" )
then
System.out.println("name = " + $p.getName());
modify($p) { setAge(41) };
end
{noformat}
However, there are still some cases which cause unexpected property reactivity.
For example, the rule below causes an infinite loop with executable model because "name" is considered as modified property.
{noformat}
rule R1 when
$p : Person( name == "Mario" )
then
System.out.println("name.length = " + $p.getName().length());
modify($p) { setAge(41) };
end
{noformat}
In standard-drl (DialectUtil.parseModifiedProperties), "getter + otherMethod" chain is considered that the property is modified. So excutable model follows the same.
However, executable model evaluates all method calls in RHS while standard-drl evaluates only direct statements like "setName("AAA");" or "getName().xxx();". executable model also should follow.
was:
The rule below causes infinite loop with executable model because "name" is considered as modified property.
{noformat}
rule R1 when
$p : Person( name == "Mario" )
then
System.out.println("name.length = " + $p.getName().length());
modify($p) { setAge(41) };
end
{noformat}
In standard-drl (DialectUtil.parseModifiedProperties), "getter + otherMethod" chain is considered that the property is modified.
https://github.com/kiegroup/drools/blob/master/drools-compiler/src/main/java/org/drools/compiler/rule/builder/dialect/DialectUtil.java#L698-L700
Executable model follows the approach in this commit:
https://github.com/kiegroup/drools/commit/fc924465437919d5b6bd99849ee595e6e7ebf957
but executable model evaluates method calls outside of modify block while standard-drl evaluates only inside modify block.
> Wrong property reactivity with non getter chain of argume
> ---------------------------------------------------------
>
> Key: DROOLS-5237
> URL: https://issues.redhat.com/browse/DROOLS-5237
> Project: Drools
> Issue Type: Bug
> Components: executable model
> Affects Versions: 7.36.0.Final
> Reporter: Toshiya Kobayashi
> Assignee: Toshiya Kobayashi
> Priority: Major
>
> DROOLS-5025 solves a case like this by exclude getter property from property reactivity mask.
> {noformat}
> rule R1 when
> $p : Person( name == "Mario" )
> then
> System.out.println("name = " + $p.getName());
> modify($p) { setAge(41) };
> end
> {noformat}
> However, there are still some cases which cause unexpected property reactivity.
> For example, the rule below causes an infinite loop with executable model because "name" is considered as modified property.
> {noformat}
> rule R1 when
> $p : Person( name == "Mario" )
> then
> System.out.println("name.length = " + $p.getName().length());
> modify($p) { setAge(41) };
> end
> {noformat}
> In standard-drl (DialectUtil.parseModifiedProperties), "getter + otherMethod" chain is considered that the property is modified. So excutable model follows the same.
> However, executable model evaluates all method calls in RHS while standard-drl evaluates only direct statements like "setName("AAA");" or "getName().xxx();". executable model also should follow.
--
This message was sent by Atlassian Jira
(v7.13.8#713008)
More information about the jboss-jira
mailing list