Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 359512 - NullPointerException in TaglibIndex due to race condition.
Summary: NullPointerException in TaglibIndex due to race condition.
Status: RESOLVED FIXED
Alias: None
Product: WTP Source Editing
Classification: WebTools
Component: jst.jsp (show other bugs)
Version: 3.3.1   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 3.3.2   Edit
Assignee: Nick Sandonato CLA
QA Contact: Nick Sandonato CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-30 01:41 EDT by Andrew McCulloch CLA
Modified: 2011-10-11 16:32 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew McCulloch CLA 2011-09-30 01:41:58 EDT
Build Identifier: M20110909-1335

TaglibIndex is not thread safe which can result in an NPE.

	void fireCurrentDelta(Object trigger) {
		if (fCurrentTopLevelDelta != null) {
			fCurrentTopLevelDelta.trigger = trigger;
			ITaglibIndexDelta delta = fCurrentTopLevelDelta;
			fCurrentTopLevelDelta = null;
			fireTaglibDelta(delta);
		}
	}

... is not protected against multiple thread access so it is possible that fCurrentTopLevelDelta will be non-null when 2 threads enter the 'if' block and be subsequently set to null by the first thread before the second thread executes the statement 'ITaglibIndexDelta delta = fCurrentTopLevelDelta;'.  This would cause a NullPointerException in fireTaglibDelta(delta) since delta will be null.

Reproducible: Sometimes

Steps to Reproduce:
This is a race condition and I have only had the NPE logged once after thousands of executions.
Comment 1 Nick Sandonato CLA 2011-10-11 16:32:30 EDT
Nice catch, Andrew. Thanks for the report! I've synchronized the code in that block.