Bug 261722 - [search] NPE after removing a project
Summary: [search] NPE after removing a project
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.5 M6   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-01-20 16:23 EST by BensonN CLA
Modified: 2009-05-20 11:21 EDT (History)
5 users (show)

See Also:


Attachments
Proposed patch (4.37 KB, patch)
2009-03-02 12:11 EST, Frederic Fusier CLA
no flags Details | Diff
Proposed patch for R3_4_maintenance stream (4.47 KB, patch)
2009-03-17 10:19 EDT, Frederic Fusier CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.