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

All line separators in RHS in spreadsheet are escaped

    Details

      Description

      By DROOLS-3396, line separators in RHS are now escaped.

      https://github.com/kiegroup/drools/blob/7.18.0.Final/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/RhsBuilder.java#L92

      However, it affects entire RHS so if you have multiple lines in ACTION, the result would be like this.

      Output from SpreadSheetCompiler:

      rule "multiple lines in action_12"
      	when
      		$fact:Person(name == "John")
      	then
      		modify($fact){\n setAge(30),\n setAlive(false)\n}
      		/* DEBUG */\nSystem.out.println("  **  " +drools.getRule().getName() + ", $fact = " + $fact);
      end
      

      Error when building:

      line 1:15 no viable alternative at character '\'
      line 1:29 no viable alternative at character '\'
      line 1:47 no viable alternative at character '\'
      line 2:13 no viable alternative at character '\'
      [ERROR] Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.63 s <<< FAILURE! - in org.drools.decisiontable.LineBreakXLSTest
      [ERROR] testMultipleLinesInAction(org.drools.decisiontable.LineBreakXLSTest)  Time elapsed: 0.257 s  <<< ERROR!
      java.lang.NullPointerException
      	at java.lang.String.indexOf(String.java:1718)
      	at org.drools.compiler.rule.builder.dialect.DialectUtil.rewriteModifyDescr(DialectUtil.java:631)
      	at org.drools.compiler.rule.builder.dialect.DialectUtil.rewriteDescr(DialectUtil.java:580)
      	at org.drools.compiler.rule.builder.dialect.DialectUtil.fixBlockDescr(DialectUtil.java:161)
      	at org.drools.compiler.rule.builder.dialect.DialectUtil.fixBlockDescr(DialectUtil.java:119)
      	at org.drools.compiler.rule.builder.dialect.asm.AbstractASMConsequenceBuilder.consequenceContext(AbstractASMConsequenceBuilder.java:57)
      	at org.drools.compiler.rule.builder.dialect.asm.AbstractASMConsequenceBuilder.build(AbstractASMConsequenceBuilder.java:33)
      	at org.drools.compiler.rule.builder.RuleBuilder.build(RuleBuilder.java:126)
      	at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.internalAddRule(KnowledgeBuilderImpl.java:1204)
      	at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.addRule(KnowledgeBuilderImpl.java:1195)
      	at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.compileRulesLevel(KnowledgeBuilderImpl.java:1173)
      	at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.compileRules(KnowledgeBuilderImpl.java:1121)
      	at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.compileKnowledgePackages(KnowledgeBuilderImpl.java:946)
      	at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.addPackage(KnowledgeBuilderImpl.java:937)
      	at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.addPackageFromDecisionTable(KnowledgeBuilderImpl.java:371)
      	at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.addKnowledgeResource(KnowledgeBuilderImpl.java:759)
      	at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:2288)
      	at org.drools.decisiontable.LineBreakXLSTest.testMultipleLinesInAction(LineBreakXLSTest.java:53)
      	...
      

      Escaping should be done only for literal String?

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  Rikkola Toni Rikkola
                  Reporter:
                  tkobayashi Toshiya Kobayashi
                  Tester:
                  Jozef Marko
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  4 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: