Description of problem: The free form DRL area is adding semicolon after each line, even if the semicolon should not be there. This can happen for example when you chain method calls and put each method on new line, like this: new AddressBuilder() .country("Czech Republic") .city("Brno") .street("Purkynova") .build(); The editor will divide this statement into 5 (one per line) and if you try to validate the rule, it will throw validation errors (because it add the semicolon at the end of each line). This is a typicall usage of the builder classes and I think should be supported. Version-Release number of selected component (if applicable): 6.0.2.ER2 How reproducible: Always Steps to Reproduce: 1. Download and install the BPMS 6.0.2.ER2. Configure users and roles and start the server. 2. Login, create new Guided Rule. (make sure the org. unit and project are also created) 3. Add free form DRL area and insert (yes, with the new lines): System .out .println("Hello World!"); 4. Save the rule. Close the editor and re-open it. 5. Click validate Actual results: The statement has been divided into three (one statement per line). This is definitely not ideal. However the real error appears when you try to validate the rule -- validation error will appear (see the screenshot), because the editor will add";" at the end of each line, makiung the statements invalid. Expected results: The rule should be validated successfully. Ideally IMHO the statement should not be broken into multiple ones. Additional info: The "Source" tab will show the rule definition (in DRL) _without_ the semicolons, which makes me wonder if it uses different serialization (into DRL) code?
Created attachment 890786 [details] Screenshot showing the issue.
This is a problem with drools-compiler. Splitting the RHS over multiple lines when using MVEL dialect is the problem. If the Guided Rule uses the Java dialect it's OK.
Minimal DRL to replicate: rule "test" dialect "mvel" when then System .out .println("hello"); end
Fixed by https://github.com/droolsjbpm/drools/commit/c27db123c
Also this commit ( https://github.com/droolsjbpm/drools/commit/dc49920ec ) is part of the fix. It adds the necessary new lines at the end of a merged multi-line statement in order to not break debugger.
This fix mitigate the problem, e.g. it works in cases like the reported one System .out .println("hello"); but still fails in other cases a bit more difficult to disambiguate like int x = 10
Cherry-picked to 6.0.x branch with https://github.com/droolsjbpm/drools/commit/910c547fbffd91613f96877df183ee27e8c6761b and https://github.com/droolsjbpm/drools/commit/d1b0750e27c47cc1092458de8588cd2528c5306e
Using the sample System .out .println("hello"); still results in rule compilation error: Unable to Analyse Expression System .out .println("test");: [Error: no such identifier: System ] [Near : {... System .out .println("test") ....}] ^ [Line: 3, Column: 0] : [Rule name='grule'] Seems like he workbench is inserting some additional spaces between the lines. I am not sure if this is a compiler issue (not correctly handling the spaces) or rather workbench one (inserting the spaces).
Fixed by https://github.com/droolsjbpm/drools/commit/1d854c501 and cherry-picked to 6.0.x branch with https://github.com/droolsjbpm/drools/commit/397f48906
Let's pick up this fix for CR1 since we ended up doing another build.
Verified in BRMS 6.0.2 CR1.