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

Bug 312704

Summary: NPE during Servlet creation operation
Product: [WebTools] WTP Java EE Tools Reporter: Chuck Bridgham <cbridgha>
Component: jst.j2eeAssignee: Chuck Bridgham <cbridgha>
Status: RESOLVED FIXED QA Contact: Chuck Bridgham <cbridgha>
Severity: normal    
Priority: P3 CC: ccc, david_williams, jsholl
Version: 3.2Flags: david_williams: pmc_approved+
jsholl: pmc_approved? (raghunathan.srinivasan)
jsholl: pmc_approved? (naci.dai)
jsholl: pmc_approved? (deboer)
jsholl: pmc_approved? (neil.hauge)
jsholl: pmc_approved? (kaloyan)
ccc: review+
Target Milestone: 3.2 RC1   
Hardware: PC   
OS: Windows 7   
Whiteboard: PMC_approved
Attachments:
Description Flags
patch none

Description Chuck Bridgham CLA 2010-05-12 16:00:50 EDT
This exception caused by a race condition can occur during Servlet creation



!ENTRY org.eclipse.wst.common.frameworks 4 0 2010-05-03 16:07:30.859
!MESSAGE Extended Operation failure: org.eclipse.jst.j2ee.internal.web.operations.AddServletOperation
!STACK 0
java.lang.NullPointerException
	at org.eclipse.jst.j2ee.web.componentcore.util.WebArtifactEdit.modify(WebArtifactEdit.java:693)
	at com.ibm.etools.javaee.model.internal.Web25ModelProvider.modify(Web25ModelProvider.java:293)
	at org.eclipse.jst.j2ee.internal.common.operations.AddJavaEEArtifactOperation.execute(AddJavaEEArtifactOperation.java:53)
	at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl$1.run(DataModelPausibleOperationImpl.java:385)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1975)
	at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.runOperation(DataModelPausibleOperationImpl.java:410)
	at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.runOperation(DataModelPausibleOperationImpl.java:360)
	at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.doExecute(DataModelPausibleOperationImpl.java:247)

Although related fixes have made this condition unlikely, a null check is needed
Comment 1 Chuck Bridgham CLA 2010-05-12 16:54:16 EDT
Created attachment 168265 [details]
patch
Comment 2 Carl Anderson CLA 2010-05-12 16:57:31 EDT
I approve of this change.
Comment 3 Jason Sholl CLA 2010-05-12 18:46:01 EDT
    * 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. 

A rare race condition can lead to NPEs and blow up the stack.

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

No

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

Testing with UI


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

The race condition can be avoided with a simple null check.  Carl and Jason have reviewed this fix.

    * What is the risk associated with this fix? 

None.
Comment 4 David Williams CLA 2010-05-12 22:40:17 EDT
I'm not sure its correct to say "The race condition can be avoided ..." by a null check, but I agree, null checks should always be done in finally blocks before dispose.
Comment 5 Carl Anderson CLA 2010-05-13 00:06:42 EDT
Committed to HEAD for WTP 3.2 RC1