From d0c30f1b2374821d1877d25f0eea1f36fbc386cb Mon Sep 17 00:00:00 2001 From: Oleg Krasilnikov Date: Tue, 2 Oct 2007 13:36:11 +0000 Subject: [PATCH] Bug #204881 : Deadlock between PathEntryManager and CProjectDescriptionManager --- .../internal/core/model/PathEntryManager.java | 24 ++++++++++--------- .../model/CProjectDescriptionManager.java | 6 ++--- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryManager.java index 2e239e4a896..c7d369e85de 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryManager.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryManager.java @@ -1200,7 +1200,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange public void setPathEntryStore(IProject project, IPathEntryStore newStore) { IPathEntryStore oldStore = null; - synchronized (this) { + synchronized (storeMap) { oldStore = (IPathEntryStore)storeMap.remove(project); if (newStore != null) { storeMap.put(project, newStore); @@ -1213,18 +1213,20 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange } } - public synchronized IPathEntryStore getPathEntryStore(IProject project, boolean create) throws CoreException { - IPathEntryStore store = (IPathEntryStore)storeMap.get(project); - if (store == null) { - if(create == true){ - store = createPathEntryStore(project); - storeMap.put(project, store); - store.addPathEntryStoreListener(this); + public IPathEntryStore getPathEntryStore(IProject project, boolean create) throws CoreException { + synchronized (storeMap){ + IPathEntryStore store = (IPathEntryStore)storeMap.get(project); + if (store == null) { + if(create == true){ + store = createPathEntryStore(project); + storeMap.put(project, store); + store.addPathEntryStoreListener(this); + } + } else if (store instanceof AbstractCExtensionProxy){ + ((AbstractCExtensionProxy)store).updateProject(project); } - } else if (store instanceof AbstractCExtensionProxy){ - ((AbstractCExtensionProxy)store).updateProject(project); + return store; } - return store; } public IPathEntryStore createPathEntryStore(IProject project) throws CoreException { diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java index 6ba684f7e68..46d022fb17e 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java @@ -2807,13 +2807,13 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { } public void addCProjectDescriptionListener(ICProjectDescriptionListener listener, int eventTypes){ - synchronized(this){ + synchronized(fListeners){ fListeners.add(new ListenerDescriptor(listener, eventTypes)); } } public void removeCProjectDescriptionListener(ICProjectDescriptionListener listener){ - synchronized(this){ + synchronized(fListeners){ int size = fListeners.size(); ListenerDescriptor des; for(int i = 0; i < size; i++){ @@ -2827,7 +2827,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { } private ListenerDescriptor[] getListeners(){ - synchronized(this){ + synchronized(fListeners){ return (ListenerDescriptor[])fListeners.toArray(new ListenerDescriptor[fListeners.size()]); } }