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 177643 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.
[patch]
Fix v04
patch.txt (text/plain), 4.66 KB, created by
John Arthorne
on 2010-08-27 15:25:34 EDT
(
hide
)
Description:
Fix v04
Filename:
MIME Type:
Creator:
John Arthorne
Created:
2010-08-27 15:25:34 EDT
Size:
4.66 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.core.resources >Index: src/org/eclipse/core/internal/resources/NatureManager.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/NatureManager.java,v >retrieving revision 1.30 >diff -u -r1.30 NatureManager.java >--- src/org/eclipse/core/internal/resources/NatureManager.java 3 Dec 2007 04:54:22 -0000 1.30 >+++ src/org/eclipse/core/internal/resources/NatureManager.java 27 Aug 2010 19:23:25 -0000 >@@ -25,13 +25,13 @@ > */ > public class NatureManager implements ILifecycleListener, IManager { > //maps String (nature ID) -> descriptor objects >- protected Map descriptors; >+ private Map descriptors; > > //maps IProject -> String[] of enabled natures for that project >- protected Map natureEnablements; >+ private final Map natureEnablements = Collections.synchronizedMap(new HashMap(20)); > > //maps String (builder ID) -> String (nature ID) >- protected Map buildersToNatures = null; >+ private Map buildersToNatures = null; > //colour constants used in cycle detection algorithm > private static final byte WHITE = 0; > private static final byte GREY = 1; >@@ -43,7 +43,7 @@ > > /** > * Computes the list of natures that are enabled for the given project. >- * Enablement computation is subtlely different from nature set >+ * Enablement computation is subtly different from nature set > * validation, because it must find and remove all inconsistencies. > */ > protected String[] computeNatureEnablements(Project project) { >@@ -108,7 +108,7 @@ > /* (non-Javadoc) > * @see IWorkspace#getNatureDescriptor(String) > */ >- public IProjectNatureDescriptor getNatureDescriptor(String natureId) { >+ public synchronized IProjectNatureDescriptor getNatureDescriptor(String natureId) { > lazyInitialize(); > return (IProjectNatureDescriptor) descriptors.get(natureId); > } >@@ -116,7 +116,7 @@ > /* (non-Javadoc) > * @see IWorkspace#getNatureDescriptors() > */ >- public IProjectNatureDescriptor[] getNatureDescriptors() { >+ public synchronized IProjectNatureDescriptor[] getNatureDescriptors() { > lazyInitialize(); > Collection values = descriptors.values(); > return (IProjectNatureDescriptor[]) values.toArray(new IProjectNatureDescriptor[values.size()]); >@@ -275,7 +275,7 @@ > /** > * Marks all nature descriptors that are involved in cycles > */ >- protected void detectCycles() { >+ private void detectCycles() { > Collection values = descriptors.values(); > ProjectNatureDescriptor[] natures = (ProjectNatureDescriptor[]) values.toArray(new ProjectNatureDescriptor[values.size()]); > for (int i = 0; i < natures.length; i++) >@@ -294,7 +294,7 @@ > * Returns the ID of the project nature that claims ownership of the > * builder with the given ID. Returns null if no nature owns that builder. > */ >- public String findNatureForBuilder(String builderID) { >+ public synchronized String findNatureForBuilder(String builderID) { > if (buildersToNatures == null) { > buildersToNatures = new HashMap(10); > IProjectNatureDescriptor[] descs = getNatureDescriptors(); >@@ -310,28 +310,20 @@ > return (String) buildersToNatures.get(builderID); > } > >- protected void flushEnablements(IProject project) { >- if (natureEnablements != null) { >- natureEnablements.remove(project); >- if (natureEnablements.size() == 0) { >- natureEnablements = null; >- } >- } >+ private synchronized void flushEnablements(IProject project) { >+ natureEnablements.remove(project); > } > > /** > * Returns the cached array of enabled natures for this project, > * or null if there is nothing in the cache. > */ >- protected String[] getEnabledNatures(Project project) { >- String[] enabled; >- if (natureEnablements != null) { >- enabled = (String[]) natureEnablements.get(project); >- if (enabled != null) >- return enabled; >- } >+ protected synchronized String[] getEnabledNatures(Project project) { >+ String[] enabled = (String[]) natureEnablements.get(project); >+ if (enabled != null) >+ return enabled; > enabled = computeNatureEnablements(project); >- setEnabledNatures(project, enabled); >+ natureEnablements.put(project, enabled); > return enabled; > } > >@@ -464,15 +456,6 @@ > detectCycles(); > } > >- /** >- * Sets the cached array of enabled natures for this project. >- */ >- protected void setEnabledNatures(IProject project, String[] enablements) { >- if (natureEnablements == null) >- natureEnablements = Collections.synchronizedMap(new HashMap(20)); >- natureEnablements.put(project, enablements); >- } >- > public void shutdown(IProgressMonitor monitor) { > // do nothing > }
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 Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 307587
:
177513
|
177601
|
177612
| 177643 |
185251
|
185303
|
188503
|
188516
|
189502
|
189520