mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 02:06:01 +02:00
Fix and test for 196290: Deadlock during project creation
This commit is contained in:
parent
37107e83e1
commit
5894ebf4d9
2 changed files with 40 additions and 18 deletions
|
@ -12,8 +12,6 @@
|
|||
|
||||
package org.eclipse.cdt.core.cdescriptor.tests;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import junit.extensions.TestSetup;
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.Test;
|
||||
|
@ -28,7 +26,6 @@ import org.eclipse.cdt.core.ICDescriptorListener;
|
|||
import org.eclipse.cdt.core.ICDescriptorOperation;
|
||||
import org.eclipse.cdt.core.ICExtensionReference;
|
||||
import org.eclipse.cdt.core.ICOwnerInfo;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.testplugin.CTestPlugin;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOMManager;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
@ -76,6 +73,7 @@ public class CDescriptorTests extends TestCase {
|
|||
suite.addTest(new CDescriptorTests("testProjectDataDelete"));
|
||||
suite.addTest(new CDescriptorTests("testConcurrentDescriptorCreation"));
|
||||
suite.addTest(new CDescriptorTests("testConcurrentDescriptorCreation2"));
|
||||
suite.addTest(new CDescriptorTests("testDeadlockDuringProjectCreation"));
|
||||
|
||||
TestSetup wrapper = new TestSetup(suite) {
|
||||
|
||||
|
@ -178,8 +176,9 @@ public class CDescriptorTests extends TestCase {
|
|||
|
||||
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=185930
|
||||
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=193503
|
||||
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=196118
|
||||
public void testConcurrentDescriptorCreation2() throws Exception {
|
||||
for (int i=0; i<100; ++i) {
|
||||
for (int i=0; i<20; ++i) {
|
||||
PDOMManager pdomMgr= (PDOMManager)CCorePlugin.getIndexManager();
|
||||
pdomMgr.shutdown();
|
||||
fProject.close(null);
|
||||
|
@ -233,6 +232,33 @@ public class CDescriptorTests extends TestCase {
|
|||
}
|
||||
}
|
||||
|
||||
public void testDeadlockDuringProjectCreation() throws Exception {
|
||||
for (int i=0; i < 10; ++i) {
|
||||
oneTimeTearDown();
|
||||
oneTimeSetUp();
|
||||
Thread t= new Thread() {
|
||||
public void run() {
|
||||
try {
|
||||
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
|
||||
Element data = desc.getProjectData("testElement0");
|
||||
data.appendChild(data.getOwnerDocument().createElement("test"));
|
||||
desc.saveProjectData();
|
||||
} catch (CoreException exc) {
|
||||
}
|
||||
}
|
||||
};
|
||||
t.start();
|
||||
|
||||
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
|
||||
Element data = desc.getProjectData("testElement0");
|
||||
data.appendChild(data.getOwnerDocument().createElement("test"));
|
||||
desc.saveProjectData();
|
||||
t.join();
|
||||
|
||||
fLastEvent = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void testDescriptorOwner() throws Exception {
|
||||
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
|
||||
ICOwnerInfo owner = desc.getProjectOwner();
|
||||
|
|
|
@ -124,7 +124,6 @@ public class CConfigBasedDescriptor implements ICDescriptor {
|
|||
}
|
||||
|
||||
private void checkApply() throws CoreException {
|
||||
synchronized (CProjectDescriptionManager.getInstance()){
|
||||
if(fApplyOnChange){
|
||||
apply(false);
|
||||
fIsDirty = false;
|
||||
|
@ -132,7 +131,6 @@ public class CConfigBasedDescriptor implements ICDescriptor {
|
|||
fIsDirty = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ICExtensionReference create(String extensionPoint, String id)
|
||||
throws CoreException {
|
||||
|
@ -323,13 +321,11 @@ public class CConfigBasedDescriptor implements ICDescriptor {
|
|||
}
|
||||
|
||||
public void saveProjectData() throws CoreException {
|
||||
synchronized (CProjectDescriptionManager.getInstance()) {
|
||||
if(CProjectDescriptionManager.getInstance().getDescriptorManager().reconsile(this, fCfgDes.getProjectDescription()))
|
||||
fIsDirty = true;
|
||||
|
||||
checkApply();
|
||||
}
|
||||
}
|
||||
|
||||
public Map getStorageDataElMap(){
|
||||
return (HashMap)fStorageDataElMap.clone();
|
||||
|
|
Loading…
Add table
Reference in a new issue