Bug 261722

Summary: [search] NPE after removing a project
Product: [Eclipse Project] JDT Reporter: BensonN <benson.ning>
Component: CoreAssignee: Frederic Fusier <frederic_fusier>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, david_audel, edwinc, jerome_lanneluc, Olivier_Thomann
Version: 3.4   
Target Milestone: 3.5 M6   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed patch
none
Proposed patch for R3_4_maintenance stream none

Description BensonN CLA 2009-01-20 16:23:47 EST
Build ID: 3.4.0

Steps To Reproduce:
After I remove a project from the workspace, I see an exception from the log file. It looks like the "Search" job is run after the project is removed. Is it possible to add a checking to JDT code to prevent the exception?

More information:
Here is the stack:

!MESSAGE Search failed:
!STACK 0
java.lang.NullPointerException
	at org.eclipse.jdt.internal.core.search.matching.PossibleMatch.getContents(Unknown Source)
	at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Unknown Source)
	at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Unknown Source)
	at org.eclipse.jdt.internal.compiler.parser.Parser.dietParse(Unknown Source)
	at org.eclipse.jdt.internal.core.search.matching.MatchLocator.parseAndBuildBindings(Unknown Source)
	at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(Unknown Source)
	at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(Unknown Source)
	at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(Unknown Source)
	at org.eclipse.jdt.internal.core.search.JavaSearchParticipant.locateMatches(Unknown Source)
	at org.eclipse.jdt.internal.core.search.BasicSearchEngine.findMatches(Unknown Source)
	at org.eclipse.jdt.internal.core.search.BasicSearchEngine.search(Unknown Source)
	at org.eclipse.jdt.core.search.SearchEngine.search(Unknown Source)
	at com.ibm.etools.annotations.core.internal.search.JavaSearchUtils.findAnnotations(Unknown Source)
	at com.ibm.etools.annotations.core.internal.listeners.TriggerAnnotationListenerImpl$InvokeChangeListenersJob.run(Unknown Source)
	at org.eclipse.core.internal.jobs.Worker.run(Unknown Source)
Comment 1 Frederic Fusier CLA 2009-03-02 07:23:53 EST
When the project is deleted, the possible match will get a null while asking for the openable source mapper in PossibleMatch.getContents() at line 70...

As the search request is run asynchronously, this kind of thing may happen (and the given stack trace looks like an example of it). So it's seems reasonable to make the Search Engine aware of this possibility and protect the following lines by a null checking.
Comment 2 Frederic Fusier CLA 2009-03-02 12:11:04 EST
Created attachment 127186 [details]
Proposed patch
Comment 3 Frederic Fusier CLA 2009-03-02 12:16:13 EST
Released for 3.5M6 in HEAD stream.
Comment 4 David Audel CLA 2009-03-10 06:12:02 EDT
Verified for 3.5M6 using I20090310-0100
Comment 5 Frederic Fusier CLA 2009-03-17 10:19:09 EDT
Created attachment 129088 [details]
Proposed patch for R3_4_maintenance stream
Comment 6 Jerome Lanneluc CLA 2009-05-20 11:21:18 EDT
Patch released in R3_4_maintenance branch.