mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-25 18:05:33 +02:00
bug 290631: Removed refresh to avoid possible deadlock
This commit is contained in:
parent
22e696677f
commit
ca49362273
2 changed files with 63 additions and 65 deletions
|
@ -31,6 +31,7 @@ import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSetting
|
||||||
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
|
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
@ -1031,8 +1032,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
|
||||||
*/
|
*/
|
||||||
public void testProjectPersistence_RealProject() throws Exception {
|
public void testProjectPersistence_RealProject() throws Exception {
|
||||||
IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName());
|
IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName());
|
||||||
String xmlStorageFileLocation;
|
IFile xmlStorageFilePrj = project.getFile(LANGUAGE_SETTINGS_PROJECT_XML);
|
||||||
String xmlOutOfTheWay;
|
String xmlPrjOutOfTheWay;
|
||||||
|
|
||||||
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
|
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
|
||||||
entries.add(new CIncludePathEntry("path0", 0));
|
entries.add(new CIncludePathEntry("path0", 0));
|
||||||
|
@ -1059,9 +1060,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
|
||||||
|
|
||||||
// write to project description
|
// write to project description
|
||||||
CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescriptionWritable);
|
CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescriptionWritable);
|
||||||
IFile xmlStorageFile = project.getFile(LANGUAGE_SETTINGS_PROJECT_XML);
|
assertTrue(xmlStorageFilePrj.exists());
|
||||||
assertTrue(xmlStorageFile.exists());
|
|
||||||
xmlStorageFileLocation = xmlStorageFile.getLocation().toOSString();
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
ICConfigurationDescription cfgDescription = getFirstConfigurationDescription(project);
|
ICConfigurationDescription cfgDescription = getFirstConfigurationDescription(project);
|
||||||
|
@ -1081,17 +1080,18 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// Move storage out of the way
|
// Move storage out of the way
|
||||||
|
String xmlStorageFileLocation = xmlStorageFilePrj.getLocation().toOSString();
|
||||||
java.io.File xmlFile = new java.io.File(xmlStorageFileLocation);
|
java.io.File xmlFile = new java.io.File(xmlStorageFileLocation);
|
||||||
xmlOutOfTheWay = xmlStorageFileLocation+".out-of-the-way";
|
xmlPrjOutOfTheWay = xmlStorageFileLocation+".out-of-the-way";
|
||||||
java.io.File xmlFileOut = new java.io.File(xmlOutOfTheWay);
|
java.io.File xmlFileOut = new java.io.File(xmlPrjOutOfTheWay);
|
||||||
xmlFile.renameTo(xmlFileOut);
|
xmlFile.renameTo(xmlFileOut);
|
||||||
assertFalse(xmlFile.exists());
|
assertFalse(xmlFile.exists());
|
||||||
assertTrue(xmlFileOut.exists());
|
assertTrue(xmlFileOut.exists());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// Should not pollute workspace area with file with no meaningful data
|
// Should not pollute workspace area with file with no meaningful data
|
||||||
String xmlWspStorageFileLocation = getStoreLocationInWorkspaceArea(project.getName()+'.'+LANGUAGE_SETTINGS_WORKSPACE_XML);
|
String xmlStorageFileWspLocation = getStoreLocationInWorkspaceArea(project.getName()+'.'+LANGUAGE_SETTINGS_WORKSPACE_XML);
|
||||||
java.io.File xmlStorageFileWsp = new java.io.File(xmlWspStorageFileLocation);
|
java.io.File xmlStorageFileWsp = new java.io.File(xmlStorageFileWspLocation);
|
||||||
assertFalse(xmlStorageFileWsp.exists());
|
assertFalse(xmlStorageFileWsp.exists());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1125,25 +1125,30 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
|
||||||
{
|
{
|
||||||
// open to double-check the data is not kept in some other kind of cache
|
// open to double-check the data is not kept in some other kind of cache
|
||||||
project.open(null);
|
project.open(null);
|
||||||
|
|
||||||
|
// check that list of providers is empty
|
||||||
ICConfigurationDescription cfgDescription = getFirstConfigurationDescription(project);
|
ICConfigurationDescription cfgDescription = getFirstConfigurationDescription(project);
|
||||||
assertNotNull(cfgDescription);
|
assertNotNull(cfgDescription);
|
||||||
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
|
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
|
||||||
|
|
||||||
List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
|
List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
|
||||||
assertEquals(0, providers.size());
|
assertEquals(0, providers.size());
|
||||||
// and close
|
|
||||||
project.close(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
// Move storage back
|
// Move storage back
|
||||||
|
String xmlStorageFileLocation = xmlStorageFilePrj.getLocation().toOSString();
|
||||||
java.io.File xmlFile = new java.io.File(xmlStorageFileLocation);
|
java.io.File xmlFile = new java.io.File(xmlStorageFileLocation);
|
||||||
xmlFile.delete();
|
xmlFile.delete();
|
||||||
assertFalse("File "+xmlFile+ " still exist", xmlFile.exists());
|
assertFalse("File "+xmlFile+ " still exist", xmlFile.exists());
|
||||||
java.io.File xmlFileOut = new java.io.File(xmlOutOfTheWay);
|
java.io.File xmlFileOut = new java.io.File(xmlPrjOutOfTheWay);
|
||||||
xmlFileOut.renameTo(xmlFile);
|
xmlFileOut.renameTo(xmlFile);
|
||||||
assertTrue("File "+xmlFile+ " does not exist", xmlFile.exists());
|
assertTrue("File "+xmlFile+ " does not exist", xmlFile.exists());
|
||||||
assertFalse("File "+xmlFileOut+ " still exist", xmlFileOut.exists());
|
assertFalse("File "+xmlFileOut+ " still exist", xmlFileOut.exists());
|
||||||
|
|
||||||
|
// Refresh storage in workspace
|
||||||
|
xmlStorageFilePrj.refreshLocal(IResource.DEPTH_ZERO, null);
|
||||||
|
assertTrue("File "+xmlStorageFilePrj+ " does not exist", xmlStorageFilePrj.exists());
|
||||||
|
|
||||||
|
// and close
|
||||||
|
project.close(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -1244,9 +1249,9 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
|
||||||
*/
|
*/
|
||||||
public void testProjectPersistence_RealProjectSplitStorage() throws Exception {
|
public void testProjectPersistence_RealProjectSplitStorage() throws Exception {
|
||||||
IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName());
|
IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName());
|
||||||
String xmlStorageFileLocation;
|
IFile xmlStorageFilePrj;
|
||||||
String xmlOutOfTheWay;
|
String xmlPrjOutOfTheWay;
|
||||||
String xmlWspStorageFileLocation;
|
String xmlStorageFileWspLocation;
|
||||||
String xmlWspOutOfTheWay;
|
String xmlWspOutOfTheWay;
|
||||||
|
|
||||||
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
|
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
|
||||||
|
@ -1274,12 +1279,10 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
|
||||||
|
|
||||||
// write to project description
|
// write to project description
|
||||||
CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescriptionWritable);
|
CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescriptionWritable);
|
||||||
IFile xmlStorageFile = project.getFile(LANGUAGE_SETTINGS_PROJECT_XML);
|
xmlStorageFilePrj = project.getFile(LANGUAGE_SETTINGS_PROJECT_XML);
|
||||||
assertTrue(xmlStorageFile.exists());
|
assertTrue(xmlStorageFilePrj.exists());
|
||||||
xmlStorageFileLocation = xmlStorageFile.getLocation().toOSString();
|
xmlStorageFileWspLocation = getStoreLocationInWorkspaceArea(project.getName()+'.'+LANGUAGE_SETTINGS_WORKSPACE_XML);
|
||||||
// TODO - cleanup names
|
java.io.File xmlStorageFileWsp = new java.io.File(xmlStorageFileWspLocation);
|
||||||
xmlWspStorageFileLocation = getStoreLocationInWorkspaceArea(project.getName()+'.'+LANGUAGE_SETTINGS_WORKSPACE_XML);
|
|
||||||
java.io.File xmlStorageFileWsp = new java.io.File(xmlWspStorageFileLocation);
|
|
||||||
assertTrue(xmlStorageFileWsp.exists());
|
assertTrue(xmlStorageFileWsp.exists());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@ -1298,20 +1301,21 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
|
||||||
assertEquals(entries.get(0), actual.get(0));
|
assertEquals(entries.get(0), actual.get(0));
|
||||||
assertEquals(entries.size(), actual.size());
|
assertEquals(entries.size(), actual.size());
|
||||||
}
|
}
|
||||||
// Move storages out of the way
|
|
||||||
{
|
{
|
||||||
java.io.File xmlFile = new java.io.File(xmlStorageFileLocation);
|
// Move storages out of the way
|
||||||
xmlOutOfTheWay = xmlStorageFileLocation+".out-of-the-way";
|
// project storage
|
||||||
java.io.File xmlFileOut = new java.io.File(xmlOutOfTheWay);
|
String xmlStorageFilePrjLocation = xmlStorageFilePrj.getLocation().toOSString();
|
||||||
|
java.io.File xmlFile = new java.io.File(xmlStorageFilePrjLocation);
|
||||||
|
xmlPrjOutOfTheWay = xmlStorageFilePrjLocation+".out-of-the-way";
|
||||||
|
java.io.File xmlFileOut = new java.io.File(xmlPrjOutOfTheWay);
|
||||||
xmlFile.renameTo(xmlFileOut);
|
xmlFile.renameTo(xmlFileOut);
|
||||||
assertFalse(xmlFile.exists());
|
assertFalse(xmlFile.exists());
|
||||||
assertTrue(xmlFileOut.exists());
|
assertTrue(xmlFileOut.exists());
|
||||||
}
|
|
||||||
{
|
// workspace storage
|
||||||
// TODO - workspace file
|
java.io.File xmlStorageFileWsp = new java.io.File(xmlStorageFileWspLocation);
|
||||||
java.io.File xmlStorageFileWsp = new java.io.File(xmlWspStorageFileLocation);
|
|
||||||
assertTrue(xmlStorageFileWsp.exists());
|
assertTrue(xmlStorageFileWsp.exists());
|
||||||
xmlWspOutOfTheWay = xmlWspStorageFileLocation+".out-of-the-way";
|
xmlWspOutOfTheWay = xmlStorageFileWspLocation+".out-of-the-way";
|
||||||
java.io.File xmlWspFileOut = new java.io.File(xmlWspOutOfTheWay);
|
java.io.File xmlWspFileOut = new java.io.File(xmlWspOutOfTheWay);
|
||||||
boolean result = xmlStorageFileWsp.renameTo(xmlWspFileOut);
|
boolean result = xmlStorageFileWsp.renameTo(xmlWspFileOut);
|
||||||
assertTrue(result);
|
assertTrue(result);
|
||||||
|
@ -1349,31 +1353,36 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
|
||||||
{
|
{
|
||||||
// open to double-check the data is not kept in some other kind of cache
|
// open to double-check the data is not kept in some other kind of cache
|
||||||
project.open(null);
|
project.open(null);
|
||||||
|
|
||||||
|
// check that list of providers is empty
|
||||||
ICConfigurationDescription cfgDescription = getFirstConfigurationDescription(project);
|
ICConfigurationDescription cfgDescription = getFirstConfigurationDescription(project);
|
||||||
assertNotNull(cfgDescription);
|
assertNotNull(cfgDescription);
|
||||||
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
|
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
|
||||||
|
|
||||||
List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
|
List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
|
||||||
assertEquals(0, providers.size());
|
assertEquals(0, providers.size());
|
||||||
|
|
||||||
|
// Move project storage back
|
||||||
|
project.open(null);
|
||||||
|
String xmlStorageFilePrjLocation = xmlStorageFilePrj.getLocation().toOSString();
|
||||||
|
java.io.File xmlFile = new java.io.File(xmlStorageFilePrjLocation);
|
||||||
|
xmlFile.delete();
|
||||||
|
assertFalse("File "+xmlFile+ " still exist", xmlFile.exists());
|
||||||
|
java.io.File xmlFileOut = new java.io.File(xmlPrjOutOfTheWay);
|
||||||
|
xmlFileOut.renameTo(xmlFile);
|
||||||
|
assertTrue("File "+xmlFile+ " does not exist", xmlFile.exists());
|
||||||
|
assertFalse("File "+xmlFileOut+ " still exist", xmlFileOut.exists());
|
||||||
|
|
||||||
|
// Refresh storage in workspace
|
||||||
|
xmlStorageFilePrj.refreshLocal(IResource.DEPTH_ZERO, null);
|
||||||
|
assertTrue("File "+xmlStorageFilePrj+ " does not exist", xmlStorageFilePrj.exists());
|
||||||
|
|
||||||
// and close
|
// and close
|
||||||
project.close(null);
|
project.close(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Move storage back
|
// Move workspace storage back
|
||||||
java.io.File xmlFile = new java.io.File(xmlStorageFileLocation);
|
java.io.File xmlWspFile = new java.io.File(xmlStorageFileWspLocation);
|
||||||
xmlFile.delete();
|
|
||||||
assertFalse("File "+xmlFile+ " still exist", xmlFile.exists());
|
|
||||||
java.io.File xmlFileOut = new java.io.File(xmlOutOfTheWay);
|
|
||||||
xmlFileOut.renameTo(xmlFile);
|
|
||||||
assertTrue("File "+xmlFile+ " does not exist", xmlFile.exists());
|
|
||||||
assertFalse("File "+xmlFileOut+ " still exist", xmlFileOut.exists());
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
// TODO
|
|
||||||
// Move storage back
|
|
||||||
java.io.File xmlWspFile = new java.io.File(xmlWspStorageFileLocation);
|
|
||||||
xmlWspFile.delete();
|
xmlWspFile.delete();
|
||||||
assertFalse("File "+xmlWspFile+ " still exist", xmlWspFile.exists());
|
assertFalse("File "+xmlWspFile+ " still exist", xmlWspFile.exists());
|
||||||
java.io.File xmlWspFileOut = new java.io.File(xmlWspOutOfTheWay);
|
java.io.File xmlWspFileOut = new java.io.File(xmlWspOutOfTheWay);
|
||||||
|
@ -1515,8 +1524,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
|
||||||
*/
|
*/
|
||||||
public void testProjectPersistence_Defaults() throws Exception {
|
public void testProjectPersistence_Defaults() throws Exception {
|
||||||
IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName());
|
IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName());
|
||||||
IFile xmlStorageFile = project.getFile(LANGUAGE_SETTINGS_PROJECT_XML);
|
IFile xmlStorageFilePrj = project.getFile(LANGUAGE_SETTINGS_PROJECT_XML);
|
||||||
assertFalse(xmlStorageFile.exists());
|
assertFalse(xmlStorageFilePrj.exists());
|
||||||
|
|
||||||
String xmlPrjWspStorageFileLocation = getStoreLocationInWorkspaceArea(project.getName()+'.'+LANGUAGE_SETTINGS_WORKSPACE_XML);
|
String xmlPrjWspStorageFileLocation = getStoreLocationInWorkspaceArea(project.getName()+'.'+LANGUAGE_SETTINGS_WORKSPACE_XML);
|
||||||
java.io.File xmlStorageFilePrjWsp = new java.io.File(xmlPrjWspStorageFileLocation);
|
java.io.File xmlStorageFilePrjWsp = new java.io.File(xmlPrjWspStorageFileLocation);
|
||||||
|
@ -1555,8 +1564,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
|
||||||
LanguageSettingsManager.serializeLanguageSettingsWorkspace();
|
LanguageSettingsManager.serializeLanguageSettingsWorkspace();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
String xmlWspStorageFileLocation = getStoreLocationInWorkspaceArea(LANGUAGE_SETTINGS_WORKSPACE_XML);
|
String xmlStorageFileWspLocation = getStoreLocationInWorkspaceArea(LANGUAGE_SETTINGS_WORKSPACE_XML);
|
||||||
String xml = ResourceHelper.getContents(xmlWspStorageFileLocation);
|
String xml = ResourceHelper.getContents(xmlStorageFileWspLocation);
|
||||||
// provider matching extension is not saved (extensions added automatically during loading providers)
|
// provider matching extension is not saved (extensions added automatically during loading providers)
|
||||||
assertFalse(xml.contains(EXTENSION_EDITABLE_PROVIDER_ID));
|
assertFalse(xml.contains(EXTENSION_EDITABLE_PROVIDER_ID));
|
||||||
// provider that differs is saved
|
// provider that differs is saved
|
||||||
|
@ -1573,8 +1582,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
|
||||||
LanguageSettingsManager.serializeLanguageSettingsWorkspace();
|
LanguageSettingsManager.serializeLanguageSettingsWorkspace();
|
||||||
|
|
||||||
// check that XML file is not created
|
// check that XML file is not created
|
||||||
String xmlWspStorageFileLocation = getStoreLocationInWorkspaceArea(LANGUAGE_SETTINGS_WORKSPACE_XML);
|
String xmlStorageFileWspLocation = getStoreLocationInWorkspaceArea(LANGUAGE_SETTINGS_WORKSPACE_XML);
|
||||||
java.io.File xmlStorageFileWsp = new java.io.File(xmlWspStorageFileLocation);
|
java.io.File xmlStorageFileWsp = new java.io.File(xmlStorageFileWspLocation);
|
||||||
assertFalse(xmlStorageFileWsp.exists());
|
assertFalse(xmlStorageFileWsp.exists());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,6 @@ import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.ListenerList;
|
import org.eclipse.core.runtime.ListenerList;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.core.runtime.jobs.ILock;
|
import org.eclipse.core.runtime.jobs.ILock;
|
||||||
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
|
||||||
import org.eclipse.core.runtime.jobs.Job;
|
import org.eclipse.core.runtime.jobs.Job;
|
||||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||||
import org.eclipse.core.runtime.preferences.InstanceScope;
|
import org.eclipse.core.runtime.preferences.InstanceScope;
|
||||||
|
@ -989,16 +988,6 @@ public class LanguageSettingsProvidersSerializer {
|
||||||
public static void loadLanguageSettings(ICProjectDescription prjDescription) {
|
public static void loadLanguageSettings(ICProjectDescription prjDescription) {
|
||||||
IProject project = prjDescription.getProject();
|
IProject project = prjDescription.getProject();
|
||||||
IFile storeInPrjArea = getStoreInProjectArea(project);
|
IFile storeInPrjArea = getStoreInProjectArea(project);
|
||||||
try {
|
|
||||||
Job currentJob = Job.getJobManager().currentJob();
|
|
||||||
ISchedulingRule currentRule = (currentJob != null) ? currentJob.getRule() : null;
|
|
||||||
if ((currentRule == null || currentRule.contains(storeInPrjArea)) && !ResourcesPlugin.getWorkspace().isTreeLocked()) {
|
|
||||||
storeInPrjArea.refreshLocal(IResource.DEPTH_ZERO, null);
|
|
||||||
}
|
|
||||||
} catch (Throwable e) {
|
|
||||||
// ignore failure
|
|
||||||
CCorePlugin.log("Internal Error trying to call IResourse.refreshLocal()", e); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
if (storeInPrjArea.exists()) {
|
if (storeInPrjArea.exists()) {
|
||||||
Document doc = null;
|
Document doc = null;
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Add table
Reference in a new issue