Bug 281317 - [search] An internal error occurred during: "Java Search".
Summary: [search] An internal error occurred during: "Java Search".
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.5.1   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-06-24 04:12 EDT by utilisateur_768 CLA
Modified: 2009-08-27 15:19 EDT (History)
3 users (show)

See Also:
Olivier_Thomann: review+


Attachments
Proposed patch (1.44 KB, patch)
2009-06-24 08:58 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 utilisateur_768 CLA 2009-06-24 04:12:36 EDT
Build id: I20090528-2000

Today, i selected a method name (in its declaration), and then from the popup menu, i launched a search for references in the project. I got the following exception. If i try again, i get it again.

java.lang.NullPointerException
at org.eclipse.jdt.internal.compiler.util.SimpleSet.add(SimpleSet.java:38)
at org.eclipse.jdt.internal.core.search.IndexSelector.getFocusedElements(IndexSelector.java:126)
at org.eclipse.jdt.internal.core.search.IndexSelector.canSeeFocus(IndexSelector.java:52)
at org.eclipse.jdt.internal.core.search.matching.MatchLocator.workingCopiesThatCanSeeFocus(MatchLocator.java:216)
at org.eclipse.jdt.internal.core.search.matching.MatchLocator.addWorkingCopies(MatchLocator.java:172)
at org.eclipse.jdt.internal.core.search.BasicSearchEngine.findMatches(BasicSearchEngine.java:222)
at org.eclipse.jdt.internal.core.search.BasicSearchEngine.search(BasicSearchEngine.java:507)
at org.eclipse.jdt.core.search.SearchEngine.search(SearchEngine.java:551)
at org.eclipse.jdt.internal.ui.search.JavaSearchQuery.run(JavaSearchQuery.java:144)
at org.eclipse.search2.internal.ui.InternalSearchUI$InternalSearchJob.run(InternalSearchUI.java:91)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Comment 1 Frederic Fusier CLA 2009-06-24 05:07:31 EDT
Would it be possible to zip the project and attached it to the bug (if not too big or not containing confidential code)? If this is not possible, try to reproduce with a similar test case in a new workspace...

TIA
Comment 2 utilisateur_768 CLA 2009-06-24 05:14:31 EDT
I will try, but after restarting eclipse, everything is fine. My guess is that the indexer must "mix" same type from different project, since before searching the reference, i was working on a "clone" project, and then i decied to switch to the original project and then the bug happened. The steps were: create a patch from the clone project, apply to the original project, and close the clone project.
Comment 3 Frederic Fusier CLA 2009-06-24 05:23:54 EDT
Were you editing the file where you selected the method and launched the search?

(In reply to comment #2)
> I will try, but after restarting eclipse, everything is fine. My guess is that
> the indexer must "mix" same type from different project, since before searching
> the reference, i was working on a "clone" project, and then i decied to switch
> to the original project and then the bug happened. The steps were: create a
> patch from the clone project, apply to the original project, and close the
> clone project.
> 
I guess that "clone" means copied (e.g. from copy/paste), am I right?
Comment 4 utilisateur_768 CLA 2009-06-24 05:27:17 EDT
Yes i was editing the file.

No "clone" mean a java project "synced" to the same CVS module, but on a branch instead of the HEAD.
Comment 5 Frederic Fusier CLA 2009-06-24 05:33:54 EDT
(In reply to comment #4)
> No "clone" mean a java project "synced" to the same CVS module, but on a branch
> instead of the HEAD.
> 
So, you didn't have the project and its clone in the same workspace, did you?
Comment 6 utilisateur_768 CLA 2009-06-24 05:37:48 EDT
(In reply to comment #5)
> So, you didn't have the project and its clone in the same workspace, did you?

Yes i had.
Comment 7 Frederic Fusier CLA 2009-06-24 05:45:22 EDT
(In reply to comment #6)
> (In reply to comment #5)
> > So, you didn't have the project and its clone in the same workspace, did you?
> 
> Yes i had.
> 
Not sure to understand, then. How could you have two different branches of the same project in the same workspace as the project still has the same name...!? The standard UI to import project from CVS would not allow you to do this. Instead, it replaces the existing version with the other one... So, did you rename one of the branch of the project or did you use other special features I'm not aware of?
Comment 8 utilisateur_768 CLA 2009-06-24 05:48:16 EDT
(In reply to comment #7)
> Not sure to understand, then. How could you have two different branches of the
> same project in the same workspace as the project still has the same name...!?
> The standard UI to import project from CVS would not allow you to do this.
> Instead, it replaces the existing version with the other one... So, did you
> rename one of the branch of the project or did you use other special features
> I'm not aware of?

The project has not the same name. I create the project with a different name, and then do "Checkout as..." in existing project.
Comment 9 Frederic Fusier CLA 2009-06-24 05:55:28 EDT
(In reply to comment #8)
> The project has not the same name. I create the project with a different name,
> and then do "Checkout as..." in existing project.
> 
OK, thanks

2 other questions:
1) could you reproduce the NPE if you edit again the file, modify it to make it "dirty" and re-launched the search one the same selected method?
2) Are there compiler/builder errors in your workspace (typically problems with projects classpath)?
Comment 10 utilisateur_768 CLA 2009-06-24 06:00:13 EDT
(In reply to comment #9)
> 2 other questions:
> 1) could you reproduce the NPE if you edit again the file, modify it to make it
> "dirty" and re-launched the search one the same selected method?

nope, i try on the original file, and on the clone project, without any error

> 2) Are there compiler/builder errors in your workspace (typically problems with
> projects classpath)?
yes there is a few compiler error on some other java project.
Comment 11 Frederic Fusier CLA 2009-06-24 06:06:45 EDT
OK, thanks for your time. Unfortunately, it would be difficult to find a reproducible test case. Saying that, I looked at the code closely, and it's obvious that the getFocusedElements(...) method can have a null focusElement, hence explains the NPE you got...
Comment 12 Frederic Fusier CLA 2009-06-24 08:58:12 EDT
Created attachment 139981 [details]
Proposed patch

Add a check before adding the focused element in the set. Also improve return when there's finally no focused elements...
Comment 13 Frederic Fusier CLA 2009-06-24 09:02:02 EDT
Olivier,

This is an unexpected NPE preventing user to perform basic search action, hence according to our process could be a candidate for 3.5.1. Could you please review the patch and let me know if you agree?
Comment 14 Frederic Fusier CLA 2009-06-24 11:07:59 EDT
Note that the patch does not contain any test as I was not able to find one which reproduces the NPE... :-(
Comment 15 Olivier Thomann CLA 2009-06-24 11:12:33 EDT
Patch is safe and simple.
+1 for 3.5.1.
A regression test would be welcome.
Comment 16 Frederic Fusier CLA 2009-06-24 11:33:14 EDT
Released for 3.6M1 in HEAD stream.

Unfortunately, as no reproducible test case was found, a code review will be necessary during milestones verification processes...
Comment 17 Frederic Fusier CLA 2009-06-24 11:42:57 EDT
Released for 3.5.1 in R3_5_maintenance stream.
Comment 18 Srikanth Sankaran CLA 2009-08-04 04:20:02 EDT
Verified for 3.6M1 using build I20090803-1300
Comment 19 Satyam Kandula CLA 2009-08-27 10:29:16 EDT
Verified the code in 3.5.1 build M20090826-1100
Comment 20 Olivier Thomann CLA 2009-08-27 15:19:51 EDT
Verified.