Bug 724221 (BRMS-165) - NPE in compiler for fact class w/o getters/setters
Summary: NPE in compiler for fact class w/o getters/setters
Keywords:
Status: CLOSED NEXTRELEASE
Alias: BRMS-165
Product: JBoss Enterprise BRMS Platform 5
Classification: JBoss
Component: unspecified
Version: unspecified
Hardware: Unspecified
OS: Unspecified
high
unspecified
Target Milestone: ---
: 5.0.1
Assignee: Edson Tirelli
QA Contact:
URL: http://jira.jboss.org/jira/browse/BRM...
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2009-07-07 14:02 UTC by nwallace
Modified: 2009-09-25 11:20 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
any
Last Closed: 2009-09-01 12:22:37 UTC
Type: Bug


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker BRMS-165 0 None None None Never

Description nwallace 2009-07-07 14:02:53 UTC
Date of First Response: 2009-09-10 01:02:44
securitylevel_name: Public

A class with missing getters and setters, e.g.:
 public class Command {
	protected String  ident;
	protected Code    code;
	protected boolean refused;
	protected String  reason;
    public Command( String id, Code c ){
    	ident = id;
    	code  = c;
    }
}

used in a rule pattern such as, e.g.:
rule cleanupRefused
    when
        $c : Command( $i : ident, refused == true, $r : reason )
    then
        # whatever
end 

causes a NPE in Declaration:239 due to Declaration.readAccessor == null

This should produce a compiler error message.

NOTICE: Javadoc on constructors of class Declaration is incorrect!

Comment 1 nwallace 2009-07-07 14:04:30 UTC
Link: Added: This issue is related to JBRULES-2021


Comment 2 nwallace 2009-09-01 12:22:37 UTC
Fix in place.

Comment 3 David Le Sage 2009-09-10 05:02:44 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 null-pointer exception would occur if a fact class lacked "getters" and "setters." 

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

RESULTS of the fix (what now happens for users.)
 * The software now, correctly, displays a compiler error message instead.


Comment 4 David Le Sage 2009-09-23 05:35:39 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 Edson Tirelli 2009-09-23 18:38:47 UTC
The CAUSE (what was actually broken)
 * by design, Drools only access properties through the getter methods. A null check was missing though in drools compiler.

CONSEQUENCES of the bug (how it impacts users.)
 * A null-pointer exception would occur if a fact class lacked "getters" and "setters."

The FIX (what was changed to eliminate this bug) and
 * Added a null check for non-existing getter methods.

RESULTS of the fix (what now happens for users.)
 * The software now, correctly, displays a compiler error message instead. 

Comment 6 Dana Mison 2009-09-24 04:30:46 UTC
Hi Edson,

To clarify, what term we would we use refer to the object that the null check is applied to?

Ie, The compiler now checks that the ???? is not null.

Comment 7 Edson Tirelli 2009-09-24 14:23:37 UTC
The compiler now checks that the method accessor (getter) exists.

Comment 8 Dana Mison 2009-09-25 11:20:16 UTC
added to the BRMS 5.0 CP01 release notes as resolved:

JBRULES-2021
A rule that referenced properties of a fact that did not have "getter" or "setter" methods for those properties would cause the compiler to throw a null-pointer exception.  This occurred because the Rules compiler was not checking if the methods existed before calling them.  The compiler now performs this check and displays an appropriate compiler error message if the methods are not found.


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