From 2233d1045a5b44e345e186900ea0715a15d96195 Mon Sep 17 00:00:00 2001 From: Anton Leherbauer Date: Fri, 19 Feb 2010 09:41:24 +0000 Subject: [PATCH] Bug 301229 - Don't create BinaryRunner inside synchronized block --- .../internal/core/model/CModelManager.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java index bf5bd30d1e9..d6e41de321f 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java @@ -473,8 +473,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang try { fileStore = EFS.getStore(locationURI); } catch (CoreException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); + CCorePlugin.log(e1); return null; } @@ -758,7 +757,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang try { cproject.close(); } catch (CModelException e) { - e.printStackTrace(); + CCorePlugin.log(e); } binaryParsersMap.remove(project); @@ -773,13 +772,21 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang public BinaryRunner getBinaryRunner(ICProject cproject) { BinaryRunner runner = null; + IProject project = cproject.getProject(); synchronized (binaryRunners) { - IProject project = cproject.getProject(); runner = binaryRunners.get(project); - if (runner == null) { - runner = new BinaryRunner(project); + } + // creation of BinaryRunner must occur outside the synchronized block + if (runner == null) { + runner = new BinaryRunner(project); + } + synchronized (binaryRunners) { + if (binaryRunners.get(project) == null) { binaryRunners.put(project, runner); runner.start(); + } else { + // another thread was faster + runner = binaryRunners.get(project); } } return runner; @@ -891,7 +898,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang fire(ElementChangedEvent.POST_CHANGE); } } catch (Exception e) { - e.printStackTrace(); + CCorePlugin.log(e); } break; }