Bug 728168 - Problems when writing rhs in Rule API
Summary: Problems when writing rhs in Rule API
Keywords:
Status: VERIFIED
Alias: None
Product: JBoss Enterprise BRMS Platform 5
Classification: JBoss
Component: BRE (Expert, Fusion)
Version: BRMS 5.2.0-ER1
Hardware: Unspecified
OS: Unspecified
medium
high
Target Milestone: ---
: BRMS 5.3.0.GA
Assignee: Nobody
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-08-04 09:12 UTC by Tomas Schlosser
Modified: 2023-05-15 19:52 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed:
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker JBRULES-3355 0 Major Closed Problems when writing rhs in Rule API 2012-09-24 11:33:25 UTC

Description Tomas Schlosser 2011-08-04 09:12:36 UTC
Description of problem:
There are several problems when writing rhs of a rule in Rule API:
- if you omit rhs() you 'nullend' on the end of the rule which results in compile error
- if you put comment in rhs() like rhs("//consequences") you get '//consequencesend' which result in compile error as well

I think there should be line delimiter behind rhs and that if rhs is omitted it should result in empty string rather than "null".

KnowledgeDescr descr = DescrFactory.newPackage().name("org.sample")
.newRule().name("results in consequencesend")
  .rhs("//consequences")
.end()

.newRule().name("results in nullend")
  .lhs()
    .pattern("String").end()
  .end()
.end()

.getDescr();

Comment 1 Edson Tirelli 2012-01-19 22:24:19 UTC
Fixed. Thanks.

Comment 2 JBoss JIRA Server 2012-01-19 22:24:29 UTC
Edson Tirelli <ed.tirelli> updated the status of jira JBRULES-3355 to Resolved

Comment 3 JBoss JIRA Server 2012-01-19 22:24:34 UTC
Edson Tirelli <ed.tirelli> updated the status of jira JBRULES-3355 to Closed

Comment 5 Tomas Schlosser 2012-01-30 14:28:07 UTC
It is fixed now, thank you Edson

Comment 6 Tomas Schlosser 2012-01-31 09:34:16 UTC
The problem with missing rhs() was resolved, but the problem with missing line end remains. It is still impossible to use .rhs("#consequence").

Comment 7 JBoss JIRA Server 2012-01-31 09:36:14 UTC
Tomáš Schlosser <tschloss> updated the status of jira JBRULES-3355 to Reopened

Comment 8 JBoss JIRA Server 2012-01-31 09:36:14 UTC
Tomáš Schlosser <tschloss> made a comment on jira JBRULES-3355

The problem with missing rhs() was resolved, but the problem with missing line
end remains. It is still impossible to use .rhs("#consequence").

Comment 9 JBoss JIRA Server 2012-01-31 14:15:26 UTC
Edson Tirelli <ed.tirelli> made a comment on jira JBRULES-3355

Tomas, isn't this a different problem? # is a parser syntax sugar for comments (//) that is being deprecated. If one uses # in the rule API, it will skip the parser and the # will not be converted into //, causing a compilation error. But the error should be due to # not being a valid character in java, not because of the concatenated "end" anymore. 

Can you please double check the error message you are getting and let me know?

Comment 10 Edson Tirelli 2012-01-31 15:01:46 UTC
Tomas, I just tested it myself and my previous comment holds. The problem you see with the use of # is a different problem. The error message says it:

"no viable alternative at character '#'"

The issue here is that when using the API, people are required to use valid java/mvel code blocks as the DRL parser is not used to deal with syntax sugar like #.

On top of that, we are deprecating # as that character might be required in the future to support other features and we don't want it to clash. So I don't think we should "fix" this. Instead, documenting it as deprecated as a whole and stating that when using the API, valid java/MVEL code has to be used is probably a better solution.

What do you think?

Comment 11 Tomas Schlosser 2012-02-02 07:20:46 UTC
OK, I have tried it and '#' is not working and '//' is. Could you please add to documentation information that '#' comments are deprecated. Thank you!

Comment 12 Edson Tirelli 2012-02-02 15:09:27 UTC
I updated the documentation to state that the use of # is deprecated and added a javadoc comment to the API explicitly warning that the use of # is not supported in the consequence.

https://github.com/droolsjbpm/drools/commit/0df9873f42c295301cbdbb8bbf20be1e48c61ab8

Comment 13 JBoss JIRA Server 2012-02-02 15:23:13 UTC
Edson Tirelli <ed.tirelli> updated the status of jira JBRULES-3355 to Resolved

Comment 14 JBoss JIRA Server 2012-02-02 15:23:19 UTC
Edson Tirelli <ed.tirelli> updated the status of jira JBRULES-3355 to Closed

Comment 15 Ryan Zhang 2012-02-15 09:12:10 UTC
Please verify the issue on 5.3 ER4.

Comment 16 Tomas Schlosser 2012-02-22 08:33:18 UTC
The problem is gone and documentation will be reviewed.

Comment 17 lcarlon 2012-05-03 02:38:09 UTC
I've added a note to the release notes deprecated features section that:

Using the '#' character for single line comments has been deprecated. Users should use '//' for single line comments.

Comment 18 lcarlon 2012-05-03 02:43:55 UTC
Comment section of the docs updated to reflect this change. The docs should be live on the internal stage within the hour:

http://documentation-stage.bne.redhat.com/docs/en-US/JBoss_Enterprise_BRMS_Platform/5/html/JBoss_Rules_5_Reference_Guide/sect-comments.html

Comment 19 lcarlon 2012-05-03 02:47:23 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Including comments on the RHS of a rule when using the Rule API resulted in a compiler error.

Comment 20 lcarlon 2012-05-03 02:47:39 UTC
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -1 +1 @@
-Including comments on the RHS of a rule when using the Rule API resulted in a compiler error.+Including comments on the RHS of a rule when using the Rule API, resulted in a compiler error.

Comment 21 lcarlon 2012-05-30 05:44:12 UTC
Deleted Technical Notes Contents.

Old Contents:
Including comments on the RHS of a rule when using the Rule API, resulted in a compiler error.

Comment 22 lcarlon 2012-05-30 05:45:29 UTC
I've removed the release notes flag to prevent this issue from showing up in the resolved section of the release notes as it has been added to the deprecated section of the release notes.


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