Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 326239

Summary: Throw an exception when creating a RuleApplication with "null" as the rule
Product: [Modeling] EMFT.Henshin Reporter: Felix Rieger <riegerf>
Component: CoreAssignee: Enrico Biermann <enrico>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: henshin.stj
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Felix Rieger CLA 2010-09-25 14:23:06 EDT
Throw an exception when creating a RuleApplication with "null" as the rule.

This makes debugging easier, as RuleApplications are usually created near Rules in the code, whereas method calls on RuleApplications are more likely to be found in various locations.
Debugging will be made easier when a NullPointerException (or any other Exception) is thrown directly when the RuleApplication is created, as it is highly unlikely passing "null" as the Rule is intended by the developer. Furthermore, when calling methods on RuleApplications created with "null" Rules it is not immediately obvious what provoked the exception.

Rule testRule = findRuleByName("Nonexistent rule");		// returns null
RuleApplication testRuleApplication = new RuleApplication(testRule, engine);		// no exception is thrown, but should throw exception
testRuleApplication.findAllMatches		// throws NullPointerException
Comment 1 Enrico Biermann CLA 2010-10-04 04:46:41 EDT
Fixed.

RuleApplication and UnitApplication should throw an NPE if any required parameter is null.