Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-7195

Modify syntax fails when using executable model, works with mvel runtime (nested properties)

    XMLWordPrintable

Details

    • 2022 Week 41-43 (from Oct 10), 2022 Week 44-46 (from Oct 31), 2022 Week 47-49 (from Nov 21), 2022 Week 50-02 (from Dec 12)
    • 3
    • Hide

      This project reproduces it: https://github.com/flozano/drools-issues

      The test class is ModifyTest, methods maxNumberOfRules_getterSyntax (working case) and maxNumberOfRules_mvelSyntax (failing case).

       

      ~/tmp ❯ git clone git@github.com:flozano/drools-issues.git
      Cloning into 'drools-issues'...
      remote: Enumerating objects: 73, done.
      remote: Counting objects: 100% (73/73), done.
      remote: Compressing objects: 100% (47/47), done.
      remote: Total 73 (delta 12), reused 68 (delta 9), pack-reused 0
      Receiving objects: 100% (73/73), 72.73 KiB | 730.00 KiB/s, done.
      Resolving deltas: 100% (12/12), done.
      ~/tmp took 2s ❯ cd drools-issues
      ~/tmp/drools-issues  main ❯ ./gradlew build
      To honour the JVM settings for this build a single-use Daemon process will be forked. See https://docs.gradle.org/7.4.2/userguide/gradle_daemon.html#sec:disabling_the_daemon.
      Daemon will be stopped at the end of the build
      
      > Task :test FAILED
      
      ModifyTest > maxNumberOfRules_mvelSyntax(RuntimeType) > drools.issues.ModifyTest.maxNumberOfRules_mvelSyntax(RuntimeType)[2] FAILED
          drools.issues.executor.InvalidRulesException at ModifyTest.java:37
      
      4 tests completed, 1 failed
      
      FAILURE: Build failed with an exception.
      
      * What went wrong:
      Execution failed for task ':test'.
      > There were failing tests. See the report at: file:///Users/flozano/tmp/drools-issues/build/reports/tests/test/index.html
      
      * Try:
      > Run with --stacktrace option to get the stack trace.
      > Run with --info or --debug option to get more log output.
      > Run with --scan to get full insights.
      
      * Get more help at https://help.gradle.org
      
      BUILD FAILED in 4s
      5 actionable tasks: 5 executed
      ~/tmp/drools-issues  main took 5s ❯
      
      Show
      This project reproduces it: https://github.com/flozano/drools-issues The test class is ModifyTest , methods maxNumberOfRules_getterSyntax (working case) and maxNumberOfRules_mvelSyntax (failing case).   ~/tmp ❯ git clone git@github.com:flozano/drools-issues.git Cloning into 'drools-issues'... remote: Enumerating objects: 73, done. remote: Counting objects: 100% (73/73), done. remote: Compressing objects: 100% (47/47), done. remote: Total 73 (delta 12), reused 68 (delta 9), pack-reused 0 Receiving objects: 100% (73/73), 72.73 KiB | 730.00 KiB/s, done. Resolving deltas: 100% (12/12), done. ~/tmp took 2s ❯ cd drools-issues ~/tmp/drools-issues  main ❯ ./gradlew build To honour the JVM settings for this build a single-use Daemon process will be forked. See https://docs.gradle.org/7.4.2/userguide/gradle_daemon.html#sec:disabling_the_daemon. Daemon will be stopped at the end of the build > Task :test FAILED ModifyTest > maxNumberOfRules_mvelSyntax(RuntimeType) > drools.issues.ModifyTest.maxNumberOfRules_mvelSyntax(RuntimeType)[2] FAILED drools.issues.executor.InvalidRulesException at ModifyTest.java:37 4 tests completed, 1 failed FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':test'. > There were failing tests. See the report at: file:///Users/flozano/tmp/drools-issues/build/reports/tests/test/index.html * Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. * Get more help at https://help.gradle.org BUILD FAILED in 4s 5 actionable tasks: 5 executed ~/tmp/drools-issues  main took 5s ❯
    • Compatibility/Configuration
    • Workaround Exists
    • Hide

      Use getter/setter in modify block. For example)

      modify($p) { getAddress().getVisitors().setValue(1) }
      

       

      Show
      Use getter/setter in modify block. For example) modify($p) { getAddress().getVisitors().setValue(1) }  
    • Set a Value
    • NEW
    • NEW
    • ---
    • ---

    Description

      When using modify keyword, using this was allowed in DRL with mvel:

      package drools.issues;
      dialect "mvel"
      
      
      rule "Modify fact without noloop will finish because of max number of executions"
        when
          $p:drools.issues.model.Person(address.visitors.value >= 0)
        then
          modify($p) { address.visitors.setValue(1) }
      end 

      but now it fails with executable model, these messages are generated:

      Message [id=1, level=ERROR, path=src/main/java/drools/issues/PE8/LambdaConsequenceE8EF572C5F769FC95AE898113C2F8B70.java, line=21, column=718
         text=address.visitors cannot be resolved to a type]
      Message [id=2, level=ERROR, path=src/main/java/drools/issues/PE8/LambdaConsequenceE8EF572C5F769FC95AE898113C2F8B70.java, line=0, column=0
         text=Java source of src/main/java/drools/issues/PE8/LambdaConsequenceE8EF572C5F769FC95AE898113C2F8B70.java in error:
      package drools.issues.PE8;
      
      
      import static drools.issues.RulesDAD2D3B10D8BA86B61E204CF7EB94CC9.*;
      import drools.issues.*;
      import org.drools.modelcompiler.dsl.pattern.D;
      
      
      @org.drools.compiler.kie.builder.MaterializedLambda()
      public enum LambdaConsequenceE8EF572C5F769FC95AE898113C2F8B70 implements org.drools.model.functions.Block1<drools.issues.model.Person>, org.drools.model.functions.HashedExpression {
      
      
          INSTANCE;
      
      
          public static final String EXPRESSION_HASH = "D8F99B450BB690F8DC1774FBAFDCAFD9";
      
      
          public java.lang.String getExpressionHash() {
              return EXPRESSION_HASH;
          }
      
      
          @Override()
          public void execute(drools.issues.model.Person $p) throws java.lang.Exception {
              {
                  address.visitors.setValue(1);
              }
          }
      }
      ] 

      the model executor compiler does not take into account that address is a property of Person.

      However, when using this syntax in modify:

      package drools.issues;
      dialect "mvel"
      
      
      rule "Modify fact without noloop will finish because of max number of executions"
        when
          $p:drools.issues.model.Person(address.visitors.value >= 0)
        then
          modify($p) { getAddress().getVisitors().setValue(1) }
      end 

      both mvel runtime and executable model work well.

       

      Attachments

        Issue Links

          Activity

            People

              rhn-support-tkobayas Toshiya Kobayashi
              flozano@gmail.com Francisco Alejandro Lozano López
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: