diff options
| author | Jayaprakash Arthanareeswaran | 2012-02-17 03:48:54 +0000 |
|---|---|---|
| committer | Jayaprakash Arthanareeswaran | 2012-02-17 03:52:04 +0000 |
| commit | e4d4ff5013f9df9fd57cdef7bafc039c1cd3f062 (patch) | |
| tree | 99100cdcc839f59f695b5e710d2411bce62fb19d | |
| parent | 6f8a1f468102cc95fa52d9b7fdbd93df1eea7638 (diff) | |
| download | eclipse.jdt.core-e4d4ff5013f9df9fd57cdef7bafc039c1cd3f062.tar.gz eclipse.jdt.core-e4d4ff5013f9df9fd57cdef7bafc039c1cd3f062.tar.xz eclipse.jdt.core-e4d4ff5013f9df9fd57cdef7bafc039c1cd3f062.zip | |
HEAD - Fix for 368152: ConcurrentModificationException on startup in
ExternalFoldersManager.createPendingFolders
3 files changed, 21 insertions, 29 deletions
diff --git a/org.eclipse.jdt.core/buildnotes_jdt-core.html b/org.eclipse.jdt.core/buildnotes_jdt-core.html index 1c817fad49..ab3c1f7729 100644 --- a/org.eclipse.jdt.core/buildnotes_jdt-core.html +++ b/org.eclipse.jdt.core/buildnotes_jdt-core.html @@ -52,7 +52,9 @@ Eclipse SDK 3.8.0 - %date% - 3.8.0 M6 <h2>What's new in this drop</h2> <h3>Problem Reports Fixed</h3> -<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=244544">244544</a> +<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=368152">368152</a> +ConcurrentModificationException on startup in ExternalFoldersManager.createPendingFolders +<br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=244544">244544</a> codeSelect fails on constant declaration in anonymous and local classes <br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=291040">291040</a> codeSelect(..) does not work for a deeply nested method invocation in nested and anonymous class diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java index bd10f5abc1..188874724b 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2011 IBM Corporation and others. + * Copyright (c) 2000, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -101,7 +101,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.Hashtable; -import java.util.Iterator; import java.util.Map; import org.eclipse.core.runtime.CoreException; @@ -117,7 +116,6 @@ import org.eclipse.core.runtime.Plugin; import org.eclipse.core.runtime.QualifiedName; import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.core.runtime.jobs.ISchedulingRule; -import org.eclipse.core.runtime.jobs.Job; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; @@ -3876,7 +3874,6 @@ public final class JavaCore extends Plugin { monitor.subTask(Messages.javamodel_resetting_source_attachment_properties); final IJavaProject[] projects = manager.getJavaModel().getJavaProjects(); HashSet visitedPaths = new HashSet(); - HashSet externalPaths = new HashSet(); ExternalFoldersManager externalFoldersManager = JavaModelManager.getExternalManager(); for (int i = 0, length = projects.length; i < length; i++) { JavaProject javaProject = (JavaProject) projects[i]; @@ -3900,32 +3897,19 @@ public final class JavaCore extends Plugin { if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) { IPath entryPath = entry.getPath(); if (ExternalFoldersManager.isExternalFolderPath(entryPath) && externalFoldersManager.getFolder(entryPath) == null) { - externalPaths.add(entryPath); + externalFoldersManager.addFolder(entryPath, true); } } } } } - - ISchedulingRule rule = null; try { - // Use a schedule rule to avoid a race condition (https://bugs.eclipse.org/bugs/show_bug.cgi?id=369251) - rule = ResourcesPlugin.getWorkspace().getRuleFactory().modifyRule(externalFoldersManager.getExternalFoldersProject()); - Job.getJobManager().beginRule(rule, monitor); - - Iterator externalPathIter = externalPaths.iterator(); - while (externalPathIter.hasNext()) { - externalFoldersManager.addFolder((IPath) externalPathIter.next(), true); - } externalFoldersManager.createPendingFolders(monitor); - - } catch (JavaModelException jme) { + } + catch(JavaModelException jme) { // Creation of external folder project failed. Log it and continue; Util.log(jme, "Error while processing external folders"); //$NON-NLS-1$ - } finally { - Job.getJobManager().endRule(rule); } - // initialize delta state if (monitor != null) monitor.subTask(Messages.javamodel_initializing_delta_state); diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ExternalFoldersManager.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ExternalFoldersManager.java index d6156980e7..928b6d1c22 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ExternalFoldersManager.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ExternalFoldersManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2011 IBM Corporation and others. + * Copyright (c) 2000, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -122,7 +122,7 @@ public class ExternalFoldersManager { } while (result.exists()); if (scheduleForCreation) { if (this.pendingFolders == null) - this.pendingFolders = new HashSet(); + this.pendingFolders = Collections.synchronizedSet(new HashSet()); this.pendingFolders.add(externalFolderPath); } knownFolders.put(externalFolderPath, result); @@ -166,16 +166,22 @@ public class ExternalFoldersManager { catch(CoreException e) { throw new JavaModelException(e); } - Iterator iterator = this.pendingFolders.iterator(); - while (iterator.hasNext()) { - Object folderPath = iterator.next(); + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=368152 + // To avoid race condition (from addFolder and removeFolder, load the map elements into an array and clear the map immediately. + // The createLinkFolder being in the synchronized block can cause a deadlock and hence keep it out of the synchronized block. + Object[] arrayOfFolders = null; + synchronized (this.pendingFolders) { + arrayOfFolders = this.pendingFolders.toArray(); + this.pendingFolders.clear(); + } + + for (int i=0; i < arrayOfFolders.length; i++) { try { - createLinkFolder((IPath) folderPath, false, externalFoldersProject, monitor); + createLinkFolder((IPath) arrayOfFolders[i], false, externalFoldersProject, monitor); } catch (CoreException e) { - Util.log(e, "Error while creating a link for external folder :" + folderPath); //$NON-NLS-1$ + Util.log(e, "Error while creating a link for external folder :" + arrayOfFolders[i]); //$NON-NLS-1$ } } - this.pendingFolders.clear(); } public void cleanUp(IProgressMonitor monitor) throws CoreException { |
