Bug 1092502 - Free form DRL adds semicolons at the end of every line, breaking the multi-line statements
Summary: Free form DRL adds semicolons at the end of every line, breaking the multi-li...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss BRMS Platform 6
Classification: Retired
Component: BRE
Version: 6.0.2
Hardware: Unspecified
OS: Unspecified
high
medium
Target Milestone: CR1
: 6.0.2
Assignee: Mario Fusco
QA Contact: Tomas Schlosser
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-04-29 12:58 UTC by Petr Široký
Modified: 2014-08-06 19:54 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-08-06 19:54:35 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Screenshot showing the issue. (65.44 KB, image/png)
2014-04-29 12:59 UTC, Petr Široký
no flags Details

Description Petr Široký 2014-04-29 12:58:30 UTC
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?

Comment 1 Petr Široký 2014-04-29 12:59:11 UTC
Created attachment 890786 [details]
Screenshot showing the issue.

Comment 2 manstis 2014-04-29 13:49:11 UTC
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.

Comment 3 manstis 2014-04-29 13:50:20 UTC
Minimal DRL to replicate:

rule "test"
dialect "mvel"
when
then
System
.out
.println("hello");
end

Comment 4 Mario Fusco 2014-04-29 17:40:52 UTC
Fixed by https://github.com/droolsjbpm/drools/commit/c27db123c

Comment 5 Mario Fusco 2014-04-29 18:21:17 UTC
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.

Comment 6 Mario Fusco 2014-04-29 18:34:37 UTC
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

Comment 8 Petr Široký 2014-05-28 16:42:26 UTC
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).

Comment 9 Mario Fusco 2014-06-03 14:31:34 UTC
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

Comment 10 Rajesh Rajasekaran 2014-06-04 16:46:57 UTC
Let's pick up this fix for CR1 since we ended up doing another build.

Comment 11 Tomas Schlosser 2014-06-18 06:06:07 UTC
Verified in BRMS 6.0.2 CR1.


Note You need to log in before you can comment on or make changes to this bug.