tkobayas opened a new issue, #6350:
URL: https://github.com/apache/incubator-kie-drools/issues/6350

   Custom operator fails with executable-model.
   
   
https://github.com/apache/incubator-kie-drools/blob/main/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/CustomOperatorOnlyDrlTest.java
   
   ```
   java.lang.AssertionError: [[Message [id=1, level=ERROR, 
path=src/main/java/defaultpkg/P7C/LambdaPredicate7C27EAD9213C766B596948C3121F3FA1.java,
 line=21, column=688
      text=Type mismatch: cannot convert from String to boolean], Message 
[id=2, level=ERROR, 
path=src/main/java/defaultpkg/P7C/LambdaPredicate7C27EAD9213C766B596948C3121F3FA1.java,
 line=0, column=0
      text=Java source of 
src/main/java/defaultpkg/P7C/LambdaPredicate7C27EAD9213C766B596948C3121F3FA1.java
 in error:
   ```
   ```
   @org.drools.compiler.kie.builder.MaterializedLambda()
   public enum LambdaPredicate7C27EAD9213C766B596948C3121F3FA1 implements 
org.drools.model.functions.Predicate1<defaultpkg.Tra48>, 
org.drools.model.functions.HashedExpression {
       ...
       @Override()
       public boolean test(defaultpkg.Tra48 _this) throws java.lang.Exception {
           return _this.getName();
       }
       ...
   }
   ```
   
   Adding tests with the following rules is enough to reproduce the issue.
   ```
   rule R1
   when
      Person( name F_str[startsWith] "J")
   then
   end
   ```
   
   ```
   rule R1
   when
      $s : String()
      Person( name F_str[startsWith] $s)
   then
   end
   ```
   
   Note that non-executable-model also fails with
   ```
   java.lang.ClassCastException: class org.drools.core.common.DefaultFactHandle 
cannot be cast to class org.drools.mvel.compiler.Person 
(org.drools.core.common.DefaultFactHandle and org.drools.mvel.compiler.Person 
are in unnamed module of loader 'app')
   
        at 
org.drools.base.org.drools.mvel.compiler.Person1651689839$getName.getValue(Unknown
 Source)
        at 
org.drools.mvel.accessors.ClassFieldReader.getValue(ClassFieldReader.java:93)
        at 
org.drools.compiler.integrationtests.CustomOperatorOnlyDrlTest$F_StrEvaluator.evaluateCachedLeft(CustomOperatorOnlyDrlTest.java:209)
   ```
    if running ksession.insert/fireAllRules, but fixing `F_StrEvaluator` (e.g. 
`extractor.getValue(valueResolver, factHandle);` -> 
`extractor.getValue(valueResolver, factHandle.getObject());`) would solve it.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to