Bug 724216 (BRMS-159)

Summary: No access to context in a constraint
Product: [JBoss] JBoss Enterprise BRMS Platform 5 Reporter: nwallace <nwallace>
Component: unspecifiedAssignee: Kris Verlaenen <kris.verlaenen>
Status: CLOSED NEXTRELEASE QA Contact:
Severity: unspecified Docs Contact:
Priority: high    
Version: unspecified   
Target Milestone: ---   
Target Release: 5.0.1   
Hardware: Unspecified   
OS: Unspecified   
URL: http://jira.jboss.org/jira/browse/BRMS-159
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-09-01 12:20:15 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:

Description nwallace 2009-07-07 13:24:40 UTC
Date of First Response: 2009-09-10 00:50:45
securitylevel_name: Public

Say I have a class Job with a method isFinished() that returns boolean. Also in a process context, I have a variable "job" of the type "Job". In a constraint on a split node, the following happens:

a) When the constraint is in mvel dialect, the code "((Job)job).finished" is correct.
b) When the constraint is in Java dialect, the code "Job j = (Job)(context.getVariable("job"));" gets me the following compilation error:

Process Compilation error : org.drools.lang.descr.ProcessDescr@48f675
	[omitted] (27:1248) : context cannot be resolved

The documentation of this is quite clear: "Code constraints are expressions that return a boolean value. They have access to the context variable. MVEL code constraints also have direct access to the variables."

Therefore I think this is a bug.

Comment 1 nwallace 2009-07-07 13:25:41 UTC
Link: Added: This issue is related to JBRULES-1978


Comment 2 nwallace 2009-09-01 12:20:15 UTC
Fix in place.

Comment 3 David Le Sage 2009-09-10 04:50:45 UTC
For documenting this in the Release Notes, can you please confirm the following and fill in the missing information. Dot point explanations are fine:

The CAUSE (what was actually broken)
 * 

CONSEQUENCES of the bug (how it impacts users.)
 *  A Boolean value was not returned correctly when a constraint on a split node was written in Java.
 *  Instead, a compilation error occurred.

The FIX (what was changed to eliminate this bug) and 
 *

RESULTS of the fix (what now happens for users.)
 * 

Comment 4 David Le Sage 2009-09-23 05:32:55 UTC
We are still awaiting the outstanding information for the Release Notes on this one.  Please provide it as soon as possible. Thanks.

Comment 5 Kris Verlaenen 2009-09-23 12:58:31 UTC
The CAUSE (what was actually broken)
 * variable resolution wasn't working as expected in code constraints

CONSEQUENCES of the bug (how it impacts users.)
 * a compilation error occurred when using context or variables in code constraints

The FIX (what was changed to eliminate this bug) and
 * automatically inject context, kcontext and process variables as known java parameters

RESULTS of the fix (what now happens for users.)
 * code constraints now have direct access to process variables and kcontext

Comment 6 Dana Mison 2009-10-05 06:52:36 UTC
added to the 5.0.CP01 release notes as resolved:

JBRULES-1978
A compilation error would occur when attempting to access context or process variables in code constraints. This was caused by variable resolution not working as expected. This issue has been fixed by automatically injecting context, kcontext, and process variables as known Java parameters so that code constraints now have direct access to process variables and kcontext.