[jboss-jira] [JBoss JIRA] (DROOLS-3653) Unexpected node sharing by function with equals

Toshiya Kobayashi (Jira) issues at jboss.org
Thu Feb 14 02:12:00 EST 2019


    [ https://issues.jboss.org/browse/DROOLS-3653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13695311#comment-13695311 ] 

Toshiya Kobayashi commented on DROOLS-3653:
-------------------------------------------

Sent a unit test PR
https://github.com/kiegroup/drools/pull/2255


> Unexpected node sharing by function with equals
> -----------------------------------------------
>
>                 Key: DROOLS-3653
>                 URL: https://issues.jboss.org/browse/DROOLS-3653
>             Project: Drools
>          Issue Type: Bug
>          Components: core engine
>    Affects Versions: 7.17.0.Final
>            Reporter: Toshiya Kobayashi
>            Assignee: Mario Fusco
>            Priority: Major
>              Labels: support
>
> Under the condition:
> - LHS has a constraint which calls a function
> - The function's argument contains "=="
> - The constraint itself uses "==" for comparison
> So the rules look like this:
> {noformat}
> package com.sample
> import org.drools.compiler.Person;
> function int myFunction(String expression, int value) {
>   if (expression.equals("param == 10") && value == 10) {
>     return 1;
>   }
>   return 0;
> }
> rule R1
>     when
>         $p: Person(myFunction("param == 10", age) == 1)
>     then
> end
> rule R2
>     when
>         $p: Person(myFunction("param == 20", age) == 1)
>     then
> end
> {noformat}
> In this case, AlphaNodes are shared so both rules match against a fact which should match only R1 (Person(age = 10)).
> Dump by ReteDumper
> {noformat}
> [EntryPointNode(1) EntryPoint::DEFAULT ] on Partition(MAIN)
>     [ObjectTypeNode(2)::EntryPoint::DEFAULT objectType=[ClassObjectType class=org.drools.core.reteoo.InitialFactImpl] expiration=-1ms ] on Partition(MAIN)
>     [ObjectTypeNode(3)::EntryPoint::DEFAULT objectType=[ClassObjectType class=org.drools.compiler.Person] expiration=-1ms ] on Partition(MAIN)
>         [AlphaNode(4) constraint=myFunction("param == 10", age) == 1] on Partition(1) d 0 i 0
>             [LeftInputAdapterNode(5)] on Partition(1) Ld 0 Li 0
>                 [RuleTerminalNode(6): rule=R1] on Partition(1) d 0 i 0
>                 [RuleTerminalNode(7): rule=R2] on Partition(1) d 0 i 0
> {noformat}
> It seems to relate to MvelConstraint.equals() logic. (It doesn't take account of the text between "==" and "==")
> https://github.com/kiegroup/drools/blob/master/drools-core/src/main/java/org/drools/core/rule/constraint/MvelConstraint.java#L615-L616



--
This message was sent by Atlassian Jira
(v7.12.1#712002)


More information about the jboss-jira mailing list