[jboss-jira] [JBoss JIRA] (DROOLS-1215) import function(s) with collision on declared Pojo field names odd behavior and no warning
Matteo Mortari (JIRA)
issues at jboss.org
Tue Jul 19 13:11:00 EDT 2016
[ https://issues.jboss.org/browse/DROOLS-1215?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13267671#comment-13267671 ]
Matteo Mortari commented on DROOLS-1215:
----------------------------------------
This is not strictly related to Drools issue and more MVEL related.(in details, this is related to the order by which MVEL would resolve between imports, variables and fields, both during compilation phase and evaluation phase).
Given workarounds do exist and are effective, will close as won't fix.
Other identified workarounds (beside the original one noted above):
* in the LHS, call the getter by explicit method instead of mvel style, i.e.: avoid {{WantToKeep( condition ...}} and use {{WantToKeep( getCondition() ...}} instead.
* in the use-case presented in this reproducer, the import-star is used to enable all the (jOOQ's) DSL methods. Instead of using the import-star, do import only those DSL methods really required to avoid name conflict.
* in the use-case presented in this reproducer, use separation of concern, and keep the (jOOQ's) DSL usage in a separate DRL file, or even better refactor the (jOOQ's) DSL code into a dedicated Java class
> import function(s) with collision on declared Pojo field names odd behavior and no warning
> ------------------------------------------------------------------------------------------
>
> Key: DROOLS-1215
> URL: https://issues.jboss.org/browse/DROOLS-1215
> Project: Drools
> Issue Type: Bug
> Components: core engine
> Affects Versions: 6.4.0.Final
> Reporter: Matteo Mortari
> Assignee: Matteo Mortari
> Attachments: DROOLS-1215.zip
>
>
> Hello,
> not sure (yet) what is causing this odd behavior, but considering the following rule-base in the attached reproducer, evolved from the usual kie example archetype:
> {code}
> global java.util.Set controlSet;
> rule "will execute per each Measurement having ID color"
> no-loop
> when
> WantToKeep( condition == "color" )
> Measurement( id == "color", $colorVal : val )
> then
> controlSet.add($colorVal);
> end
> declare WantToKeep
> condition : String
> end
> rule "kickstart"
> salience 999
> when
> eval( true )
> then
> insert(new WantToKeep( "color" ));
> end
> {code}
> This works as expected until adding the following import statement:
> {code}
> import function org.jooq.impl.DSL.*;
> {code}
> and then the test will fail.
> I suspect because some "functions"/static method exists on {{org.jooq.impl.DSL}} with name "condition" which is colliding with the declared Pojo field name "condition", but I can't understand why this supposed collision happens as in the LHS I'm looking for the field not a method invocation with the {{condition()}} form.
> I'm willing to investigate more on this later, for the time being I thought worthy at least to raise this JIRA record for tracking.
> I will attach reproducer and workaround in the appropriate sections.
> Thank you,
> Ciao,
> MM
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
More information about the jboss-jira
mailing list