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

Bug 333783

Summary: AppConfig validator fails when it encounters bodiless nodes
Product: [WebTools] Java Server Faces Reporter: Yury Kats <yurykats>
Component: CoreAssignee: Ian Trimble <ian.trimble>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: raghunathan.srinivasan, xiaonan_jiang
Version: 3.2.2Flags: raghunathan.srinivasan: pmc_approved? (david_williams)
raghunathan.srinivasan: pmc_approved? (naci.dai)
deboer: pmc_approved+
raghunathan.srinivasan: pmc_approved? (neil.hauge)
raghunathan.srinivasan: pmc_approved? (kaloyan)
raghunathan.srinivasan: review+
Target Milestone: 3.2.3   
Hardware: PC   
OS: Windows XP   
Whiteboard: PMC_approved
Attachments:
Description Flags
Patch none

Description Yury Kats CLA 2011-01-07 14:51:27 EST
When faces-config file contains a bodiless node (<node />) and that node fails validation (eg, it should contain a class name), the validator throws an NPE and stops validating.

For example, if faces-config contains the following entry
	<factory>
		<application-factory />
	</factory>
the validator will choke. At the same  time, it will work correctly with identical fragment:
	<factory>
		<application-factory></application-factory>  
	</factory>

The stack trace is this:
java.lang.NullPointerException
	at org.eclipse.jst.jsf.validation.internal.appconfig.AppConfigValidationUtil.getLength(AppConfigValidationUtil.java:239)
	at org.eclipse.jst.jsf.validation.internal.appconfig.EObjectValidationVisitor.addMessageInfo(EObjectValidationVisitor.java:168)
	at org.eclipse.jst.jsf.validation.internal.appconfig.ClassNameEObjectValidationVisitor.doValidate(ClassNameEObjectValidationVisitor.java:42)
	at org.eclipse.jst.jsf.validation.internal.appconfig.EObjectValidationVisitor.validate(EObjectValidationVisitor.java:84)
	at org.eclipse.jst.jsf.validation.internal.appconfig.EObjectValidationVisitor.validate(EObjectValidationVisitor.java:107)
	at org.eclipse.jst.jsf.validation.internal.appconfig.EObjectValidationVisitor.validate(EObjectValidationVisitor.java:107)
	at org.eclipse.jst.jsf.validation.internal.appconfig.AppConfigValidator.validateModel(AppConfigValidator.java:305)
	at org.eclipse.jst.jsf.validation.internal.appconfig.AppConfigValidator.validateFile(AppConfigValidator.java:188)
	at org.eclipse.jst.jsf.validation.internal.appconfig.AppConfigValidator.validate(AppConfigValidator.java:77)
Comment 1 Yury Kats CLA 2011-01-07 14:53:28 EST
Created attachment 186310 [details]
Patch
Comment 2 Yury Kats CLA 2011-01-07 14:54:21 EST
Simple fix in AppConfigValidationUtil#getLength is attached as a patch.

Please consider for 3.2.3. Thanks.
Comment 3 Ian Trimble CLA 2011-01-20 15:32:18 EST
Raghu, please review for PMC approval - the patch is good.
Comment 4 Raghunathan Srinivasan CLA 2011-01-20 16:22:08 EST
* Explain why you believe this is a stop-ship defect. Or, if it is a "hotbug"
(requested by an adopter) please document it as such. 

This issues  breaks the validation feature

* Is there a work-around? If so, why do you believe the work-around is
insufficient? 
No workaround

* How has the fix been tested? Is there a test case attached to the bugzilla
record? Has a JUnit Test been added? 
 Manual testing.

* Give a brief technical overview. Who has reviewed this fix? 
See comment 2.

* What is the risk associated with this fix? 
low
Comment 5 Ian Trimble CLA 2011-01-21 14:56:16 EST
Committed at 2011/01/21 11:55AM PDT with 1 PMC approval vote.