Bug 281598 - [assist] Problems during content assist - if project has empty zip file in classpath
Summary: [assist] Problems during content assist - if project has empty zip file in cl...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.5.1   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 281871
  Show dependency tree
 
Reported: 2009-06-25 22:59 EDT by Balakrishnan CLA
Modified: 2009-08-27 15:20 EDT (History)
7 users (show)

See Also:
daniel_megert: pmc_approved+
david_audel: review+
daniel_megert: review+


Attachments
Error snapshot (38.68 KB, image/jpeg)
2009-06-25 22:59 EDT, Balakrishnan CLA
no flags Details
Proposed patch (4.77 KB, patch)
2009-07-07 06:00 EDT, Frederic Fusier CLA
no flags Details | Diff
New proposed patch (7.84 KB, patch)
2009-07-07 08:07 EDT, Frederic Fusier CLA
no flags Details | Diff
Final patch (10.77 KB, patch)
2009-07-08 10:45 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 Balakrishnan CLA 2009-06-25 22:59:48 EDT
Created attachment 140168 [details]
Error snapshot

Build ID: 20090619-0625

Steps To Reproduce:

1.Add a empty zip file to the project classpath

2.Type sys and press ctrl+space in a java file

3.Eclipse shows Problems during content assist and asking to disable Java proposals to avoid that message.It works fine when I am using zip file with some contents.
Comment 1 Dani Megert CLA 2009-06-26 06:29:30 EDT
>1.Add a empty zip file to the project classpath
Why should one do that?
Comment 2 Dani Megert CLA 2009-06-26 06:30:17 EDT
Can reproduce on Eclipse SDK 3.5.
Comment 3 Olivier Thomann CLA 2009-06-26 08:38:36 EDT
David, please investigate.
Comment 4 Balakrishnan CLA 2009-06-26 22:36:29 EDT
(In reply to comment #1)
> >1.Add a empty zip file to the project classpath
> Why should one do that?

We have added empty zip file to our project to make sure that developer check-in the zip file in same location. It 's working fine in previous eclipse versions 3.4.1, 3.4.2.  It would be great if i am getting fix for this issue.
Thanks in advance.
Comment 5 Dani Megert CLA 2009-06-27 03:37:45 EDT
>It 's working fine in previous eclipse versions 3.4.1, 3.4.2. 
David, what did we change here?
Comment 6 David Audel CLA 2009-06-29 04:28:35 EDT
I reproduced the problem.

I can see several exceptions in the .log. These exceptions occur when the compilation unit is opened in an editor. The same exceptions occur in 3.4.

java.util.zip.ZipException: error in opening zip file
	at java.util.zip.ZipFile.open(Native Method)
	at java.util.zip.ZipFile.<init>(ZipFile.java:203)
	at java.util.zip.ZipFile.<init>(ZipFile.java:234)
	at org.eclipse.jdt.internal.core.JavaModelManager.getZipFile(JavaModelManager.java:2419)
	at org.eclipse.jdt.internal.core.JarPackageFragmentRoot.getJar(JarPackageFragmentRoot.java:152)
	at org.eclipse.jdt.internal.core.JarPackageFragmentRoot.computeChildren(JarPackageFragmentRoot.java:78)
	at org.eclipse.jdt.internal.core.JavaProjectElementInfo.initializePackageNames(JavaProjectElementInfo.java:252)
	at org.eclipse.jdt.internal.core.JavaProjectElementInfo.getProjectCache(JavaProjectElementInfo.java:225)
	at org.eclipse.jdt.internal.core.JavaProjectElementInfo.newNameLookup(JavaProjectElementInfo.java:290)
	at org.eclipse.jdt.internal.core.JavaProject.newNameLookup(JavaProject.java:2253)
	at org.eclipse.jdt.internal.core.SearchableEnvironment.<init>(SearchableEnvironment.java:56)
	at org.eclipse.jdt.internal.core.SearchableEnvironment.<init>(SearchableEnvironment.java:63)
	at org.eclipse.jdt.internal.core.CancelableNameEnvironment.<init>(CancelableNameEnvironment.java:26)
	at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:158)
	at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:243)
	at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.makeConsistent(ReconcileWorkingCopyOperation.java:190)
	at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.executeOperation(ReconcileWorkingCopyOperation.java:89)
	at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:728)
	at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:788)
	at org.eclipse.jdt.internal.core.CompilationUnit.reconcile(CompilationUnit.java:1242)
	at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:126) 


I can not reproduce the code assist problem in 3.4.
In 3.5 the timeout is reached (the timeout was added in 3.5 and is 5sec). That's why some proposals are missing. In 3.4 the code assist operation take less than 1 sec.

Code assist indirectly call BasicSearchEngine.searchAllTypeNames() and this method seems to take most of the time of the code assist operation.
Comment 7 Frederic Fusier CLA 2009-07-06 06:44:28 EDT
The empty zip file seems to be indexed each time the search request is done, I'm investigating...
Comment 8 Frederic Fusier CLA 2009-07-06 11:52:35 EDT
Finally, this was not a problem in the index but in the SearchableEnvironment instead due to the fix for bug 250685 in the method
findTypes(char[], boolean, boolean, int, ISearchRequestor, IProgressMonitor)...

A loop was added making a search request with CANCEL_IF_NOT_READY_TO_SEARCH although the indexes will be never ready as it's not possible to build the one on the empty zip file.

I've got a patch for this soon...
Comment 9 Frederic Fusier CLA 2009-07-07 06:00:35 EDT
Created attachment 140942 [details]
Proposed patch
Comment 10 Frederic Fusier CLA 2009-07-07 06:01:32 EDT
David, could you please review?
Comment 11 Frederic Fusier CLA 2009-07-07 06:04:56 EDT
Dani, as Olivier is in vacations this week, could you give a +1 to backport this fix for 3.5.1? Then, I can put the fix in the tomorrow's maintenance build...
TIA
Comment 12 Frederic Fusier CLA 2009-07-07 08:07:22 EDT
Created attachment 140951 [details]
New proposed patch

New patch after David's initial review... This patch also fixes similar potential issue for constructors completion...
Comment 13 Dani Megert CLA 2009-07-07 09:52:57 EDT
I'm OK with fixing this for 3.5.1 and locally to this issue the patch looks good. However, we should wait for the outcome of the fix for bug 281871 which is also exactly in this area.

From a client side I found it unexpected  that the search index is never finished in the case of an unreadable JAR. I suggest to improve the Javadoc regarding this, especially the constants in IJavaSearchConstants should mention this.
Comment 14 Frederic Fusier CLA 2009-07-08 10:45:31 EDT
Created attachment 141095 [details]
Final patch

This patch also fixes issue revealed in bug 281871. Note that as we want to avoid as much as possible to use the model for such operation, the fix gives twice a chance to the indexing to be ready and to perform the search request...
Comment 15 David Audel CLA 2009-07-09 05:45:36 EDT
The patch looks good.

Use model when indeesx are not ready has currently some limitation. The camel case match is currently not supported and member types are not found.
These limitation looks acceptable because this is only when the indexes are not ready. And less proposals is better than no proposals.
Comment 16 Frederic Fusier CLA 2009-07-09 06:34:40 EDT
(In reply to comment #15)
> The patch looks good.
> 
Thanks David

Released for 3.6M1 in HEAD stream.
Comment 17 Frederic Fusier CLA 2009-07-09 07:43:06 EDT
Released for 3.5.1 in R3_5_maintenance stream.
Comment 18 Srikanth Sankaran CLA 2009-08-04 04:17:00 EDT
Verified for 3.6M1 using build I20090803-1300
Comment 19 Satyam Kandula CLA 2009-08-27 10:37:57 EDT
Verified for 3.5.1 using build M20090826-1100
Comment 20 Olivier Thomann CLA 2009-08-27 15:20:04 EDT
Verified.