Project: JDT
Bug 200456 [content assist] Content assist for static member of favorite class forgets import intermittently
Reported: 2007-08-18 15:40:48 | Status: verified fixed

Build ID: I20070809-1105 Steps To Reproduce: Sometimes, when requesting content assist for a static member of a favorite class (for example, assertTr|, expecting org.junit.Assert.assertTrue), the correct reference is inserted at the cursor, but the static import is not added to the top of the java class file. This is intermittent. It appears to be more likely to happen if: 1) The java file is large 2) There is only one possible content assistance proposal, which is then automatically inserted without further prompting More information: The problem appears to be in AbstractJavaCompletionProposal.isSupportingRequiredProposals(). Rather than calling getProposalInfo(), it reads fProposalInfo. Therefore, in a LazyJavaCompletionProposal, there is a race to see if another thread will call getProposalInfo() before isSupportingRequiredProposals() is called, resulting in the intermittent behavior above. Correcting AbstractJavaCompletionProposal to never directly read fProposalInfo should prevent the problem. Thanks!

Files changed in fix:
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/AbstractJavaCompletionProposal.java