Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 188503 Details for
Bug 307587
NatureManager is NOT threadsafe causing incorrect responses to isNatureEnabled() (and others)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
Same test but in patch
patch_307587_test.txt (text/plain), 3.68 KB, created by
Malgorzata Janczarska
on 2011-02-08 05:37:05 EST
(
hide
)
Description:
Same test but in patch
Filename:
MIME Type:
Creator:
Malgorzata Janczarska
Created:
2011-02-08 05:37:05 EST
Size:
3.68 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.core.tests.resources >Index: src/org/eclipse/core/tests/resources/NatureTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/NatureTest.java,v >retrieving revision 1.14 >diff -u -r1.14 NatureTest.java >--- src/org/eclipse/core/tests/resources/NatureTest.java 16 May 2010 02:08:05 -0000 1.14 >+++ src/org/eclipse/core/tests/resources/NatureTest.java 8 Feb 2011 10:35:52 -0000 >@@ -11,6 +11,7 @@ > package org.eclipse.core.tests.resources; > > import java.io.*; >+import java.util.Random; > import junit.framework.Test; > import junit.framework.TestSuite; > import org.eclipse.core.filesystem.EFS; >@@ -19,6 +20,7 @@ > import org.eclipse.core.internal.resources.Project; > import org.eclipse.core.resources.*; > import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.Path; > import org.eclipse.core.runtime.jobs.IJobManager; > import org.eclipse.core.runtime.jobs.Job; > import org.eclipse.core.tests.internal.resources.SimpleNature; >@@ -84,6 +86,76 @@ > ensureDoesNotExistInWorkspace(getWorkspace().getRoot()); > } > >+ private class CheckingThread extends Thread { >+ private Random random; >+ private int threadNo; >+ private String projectPath; >+ >+ public CheckingThread(Random random, int threadNo, String projectPath) { >+ super(); >+ this.random = random; >+ this.threadNo = threadNo; >+ this.projectPath = projectPath; >+ } >+ >+ public void run() { >+ try { >+ sleep(Math.abs(random.nextLong() % 10)); >+ IProject project = importProject("ProjectImported" + threadNo, projectPath); >+ assertTrue("Thread " + threadNo + " invalid nature " + NATURE_SIMPLE, project.isNatureEnabled(NATURE_SIMPLE)); >+ project.delete(true, null); >+ } catch (CoreException e) { >+ e.printStackTrace(); >+ fail(); >+ } catch (InterruptedException e) { >+ e.printStackTrace(); >+ fail(); >+ } >+ } >+ } >+ >+ protected IProject importProject(String projectName, String locationURI) throws CoreException { >+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); >+ IProjectDescription recordDescr = ResourcesPlugin.getWorkspace().loadProjectDescription(new Path(locationURI + "/" + IProjectDescription.DESCRIPTION_FILE_NAME)); >+ IProjectDescription desc = ResourcesPlugin.getWorkspace().newProjectDescription(projectName); >+ desc.setBuildSpec(recordDescr.getBuildSpec()); >+ desc.setComment(recordDescr.getComment()); >+ desc.setDynamicReferences(recordDescr.getDynamicReferences()); >+ desc.setNatureIds(recordDescr.getNatureIds()); >+ desc.setReferencedProjects(recordDescr.getReferencedProjects()); >+ project.create(desc, IResource.NONE, null); >+ project.open(null); >+ return project; >+ } >+ >+ /** >+ * Tests if newly created project will have imported nature. Includes multiple threads (see bug 307587) >+ */ >+ public void testConcurrentNatures() { >+ >+ IWorkspace ws = ResourcesPlugin.getWorkspace(); >+ IProject project = ws.getRoot().getProject("Project"); >+ ensureExistsInWorkspace(project, true); >+ setNatures("1.0", project, new String[] {NATURE_SIMPLE}, false); >+ >+ Random random = new Random(); >+ >+ int size = 50; >+ CheckingThread[] threads = new CheckingThread[size]; >+ for (int i = 0; i < size; i++) { >+ threads[i] = new CheckingThread(random, i, project.getLocation().toString()); >+ threads[i].start(); >+ } >+ for (int i = 0; i < size; i++) { >+ try { >+ threads[i].join(); >+ } catch (InterruptedException e) { >+ fail(); >+ } >+ } >+ >+ } >+ > /** > * Tests invalid additions to the set of natures for a project. > */
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 307587
:
177513
|
177601
|
177612
|
177643
|
185251
|
185303
| 188503 |
188516
|
189502
|
189520