246275 Deadlock with taglib index and JavaProject.getResolvedClasspath(boolean)
diff --git a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/taglib/ProjectDescription.java b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/taglib/ProjectDescription.java index 306829a..269d7f4 100644 --- a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/taglib/ProjectDescription.java +++ b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/taglib/ProjectDescription.java
@@ -92,6 +92,14 @@ import com.ibm.icu.text.Collator; import com.ibm.icu.util.StringTokenizer; +/** + * Contains the tag library information for a single project. + * + * * <p> + * This class is neither intended to be instantiated nor accessed by clients. + * </p> + * + */ class ProjectDescription { class DeltaVisitor implements IResourceDeltaVisitor { @@ -929,34 +937,41 @@ } private void ensureUpTodate() { - try { - LOCK.acquire(); - - if (!fBuildPathIsDirty) { + IClasspathEntry[] entries = null; + if (!fBuildPathIsDirty) { + try { + /* + * If the Java nature isn't present (or something else is + * wrong), don't check the build path. + */ + IJavaProject jproject = JavaCore.create(fProject); + if (jproject != null && jproject.exists()) { + entries = jproject.getResolvedClasspath(true); + } + } + catch (JavaModelException e) { + Logger.logException(e); + } + } + if (entries != null) { + try { + LOCK.acquire(); /* * Double-check that the number of build path entries has not * changed. This should cover most cases such as when a * library is added into or removed from a container. */ - try { - IJavaProject jproject = JavaCore.create(fProject); - if (jproject != null && jproject.exists()) { - IClasspathEntry[] entries = jproject.getResolvedClasspath(true); - fBuildPathIsDirty = (fBuildPathEntryCount != entries.length); - } - } - catch (JavaModelException e) { - Logger.logException(e); + fBuildPathIsDirty = (fBuildPathEntryCount != entries.length); + + if (fBuildPathIsDirty) { + indexClasspath(entries); + fBuildPathIsDirty = false; } } - if (fBuildPathIsDirty) { - indexClasspath(); - fBuildPathIsDirty = false; + finally { + LOCK.release(); } } - finally { - LOCK.release(); - } } private TaglibInfo extractInfo(String basePath, InputStream tldContents) { @@ -1312,6 +1327,9 @@ Logger.log(Logger.INFO, "indexed " + fProject.getName() + " contents in " + (System.currentTimeMillis() - time0) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } + /** + * @deprecated + */ void indexClasspath() { if (_debugIndexTime) time0 = System.currentTimeMillis(); @@ -1337,6 +1355,22 @@ Logger.log(Logger.INFO, "indexed " + fProject.getName() + " classpath in " + (System.currentTimeMillis() - time0) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } + void indexClasspath(IClasspathEntry[] entries) { + if (_debugIndexTime) + time0 = System.currentTimeMillis(); + fClasspathProjects.clear(); + fClasspathReferences.clear(); + fClasspathJars.clear(); + + fBuildPathEntryCount = entries.length; + for (int i = 0; i < entries.length; i++) { + indexClasspath(entries[i]); + } + + if (_debugIndexTime) + Logger.log(Logger.INFO, "indexed " + fProject.getName() + " classpath in " + (System.currentTimeMillis() - time0) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + } + /** * @param entry */ @@ -1422,7 +1456,7 @@ */ /** - * @param javaProject + * @deprecated */ private void indexClasspath(IJavaProject javaProject) { if (javaProject == null)