Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1136424

Summary: Rules using declaration inside the same pattern where the variable is declared are not compiling
Product: [JBoss] JBoss Enterprise BRMS Platform 5 Reporter: Anton Giertli <agiertli>
Component: BRE (Expert, Fusion)Assignee: Mario Fusco <mfusco>
Status: CLOSED UPSTREAM QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: BRMS 5.3.1CC: mfusco
Target Milestone: ---   
Target Release: future   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1136433 (view as bug list) Environment:
Last Closed: 2025-02-10 03:42:55 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1136433    
Attachments:
Description Flags
[0] reproducer none

Description Anton Giertli 2014-09-02 14:25:13 UTC
Created attachment 933809 [details]
[0] reproducer

Description of problem:

Following commit 
https://github.com/droolsjbpm/drools/commit/af7180bd8

caused a regression in Roll Up Patch #5

Following construct in rules
g: GenericPojo( g.getItem("ProductType) == "A" || g.getItem("ProductType) == "B" )

is no longer valid and it fails with 

"Variables can not be used inside bindings drools"

There are workarounds (see Additional Info)
but the same construct used to work in *all* previous BRMS versions


Version-Release number of selected component (if applicable):
BRMS 5.3.1 with Roll Up Patch #5 applied

How reproducible:
always

Steps to Reproduce:
1. import test project into IDE
2. add GP.jar to the classpath
3. run the class including main method

Actual results:
it fails with "Variables can not be used inside bindings drools"

Expected results:
KBase should be built successfully

Additional info:

workaround
g: GenericPojo( getItem("ProductType) == "A" || getItem("ProductType) == "B" )

or if you prefer:

g: GenericPojo( this.getItem("ProductType) == "A" || this.getItem("ProductType) == "B" )

Comment 1 Lukáš Petrovický 2014-09-02 14:50:36 UTC
(In reply to Anton Giertli from comment #0)
> Following construct in rules
> g: GenericPojo( g.getItem("ProductType) == "A" || g.getItem("ProductType) ==
> "B" )

Is this the correct code sample? It has multiple quotation marks missing, which would surely result in parse errors.

Further, qualifying getItem() with "g" is not necessary. "this" would work, and most likely just omitting the qualifier entirely. To be honest, I had no idea that qualifying it this way ever worked.

Also, in the future, I would appreciate if the bug title could be something more descriptive than "Regression". That's not a bug title, that's bug classification.

Comment 2 Anton Giertli 2014-09-02 15:02:30 UTC
Lukáš,

the code sample has been written by hand, apparently with typos, sorry for that. 

However, the decision table is attached. Just look for the rules which includes g.getItem("ProductType").genericValue() and ||.

Or navigate directly to lines 196,210,231,238 in the XLS file.

I have also changed the BZ title.

I am aware of the workaround you have mentioned - they are included in the initial bug description twice.

The original rule is not promoting best practise - Mario mentioned this too, but the issue is not with the best practise. The issue is that in the 

BRMS 5.3.1 < BRMS 5.3.1 RP5 you can compile successfully this construct, and when RP5 is applied you can't. 

I believe that the roll up patch should not break backward compatibility.

Anton.

Comment 3 Mario Fusco 2014-09-02 16:38:23 UTC
Fixed by https://github.com/droolsjbpm/drools/commit/c773a387a

Comment 6 Red Hat Bugzilla 2025-02-10 03:42:55 UTC
This product has been discontinued or is no longer tracked in Red Hat Bugzilla.