Uploaded image for project: 'Red Hat Decision Manager'
  1. Red Hat Decision Manager
  2. RHDM-838

executable-model: compilation fails if there are multiple update() for the same object in RHS.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Minor
    • None
    • 7.2.0.GA
    • BRE
      • RHDM 7.2.0
    • Hide

      avoid to call update() for the same object multiple times

      Show
      avoid to call update() for the same object multiple times
    • Hide

      run reproducer by the following command.

      $ mvn clean install -DgenerateModel=YES

      Show
      run reproducer by the following command. $ mvn clean install -DgenerateModel=YES
    • 2019 Week 05-07

    Description

      compilation fails with the following DRL.

      package com.sample;
      //generated from Decision Table
      import com.sample.Message;
      // rule values at C11, header at C6
      rule "HelloWorldXLS_11"
      	when
      		m:Message(status == Message.HELLO)
      	then
      		System.out.println(m.getMsg());
      		m.setMsg("Goodbye cruel world");update(m);
      		m.setStatus(Message.GOODBYE);update(m);
      end
      
      // rule values at C12, header at C6
      rule "HelloWorldXLS_12"
      	when
      		m:Message(status == Message.GOODBYE)
      	then
      		System.out.println(m.getMsg());
      end
      

      Here is an ERROR.

      [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile-1) on project HelloWorld: Compilation failure
      [ERROR] /tmp/HelloWorld/target/generated-sources/drools-model-compiler/main/java/com/sample/Rules47274848713b466c9cc49fe299a57c35RuleMethods0.java:[76,40] variable mask_m is already defined in method rule_HelloWorldXLS__11()

      and problematic source which is generated.

          public static org.drools.model.Rule rule_HelloWorldXLS__11() {
              final org.drools.model.Variable<com.sample.Message> var_m = D.declarationOf(com.sample.Message.class,
                                                                                          "m");
              final org.drools.model.BitMask mask_m = org.drools.model.BitMask.getPatternMask(com.sample.Message.class,
                                                                                              "msg");
              final org.drools.model.BitMask mask_m = org.drools.model.BitMask.getPatternMask(com.sample.Message.class,
                                                                                              "msg",
                                                                                              "status");
              org.drools.model.Rule rule = D.rule("com.sample",
                                                  "HelloWorldXLS_11").build(D.pattern(var_m).expr("$expr$1$",
                                                                                                  (_this) -> _this.getStatus() == Message.HELLO,
                                                                                                  D.reactOn("status")),
                                                                            D.on(var_m).execute((drools, m) -> {
                  System.out.println(m.getMsg());
                  m.setMsg("Goodbye cruel world");
                  drools.update(m,
                                mask_m);
                  m.setStatus(Message.GOODBYE);
                  drools.update(m,
                                mask_m);
              }));
              return rule;
          }
      

      If first update() (which is just after m.setMsg()) is removed, compilation works.

      Attachments

        Issue Links

          Activity

            People

              lmolteni@redhat.com Luca Molteni
              rhn-support-hmiura Hiroko Miura
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: