aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Besedin2011-03-23 14:27:59 (EDT)
committerPaul Webster2012-11-01 13:02:50 (EDT)
commitb020492d2f7d54094d3f1dee622975d245a78ae2 (patch)
tree9b292e0cfbf89e3fa52163106e792a8bf7ec8e10
parent5457ea1ed2a2c4dfefe12075780bb52d0835222f (diff)
downloadeclipse.platform.ui-b020492d2f7d54094d3f1dee622975d245a78ae2.zip
eclipse.platform.ui-b020492d2f7d54094d3f1dee622975d245a78ae2.tar.gz
eclipse.platform.ui-b020492d2f7d54094d3f1dee622975d245a78ae2.tar.bz2
Bug 323431 - [ActivityMgmt] ConcurrentModificationException when activities added dynamicallyv20121101-1702M20121101-1702
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/activities/MutableActivityManager.java54
1 files changed, 9 insertions, 45 deletions
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/activities/MutableActivityManager.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/activities/MutableActivityManager.java
index 3728443..f306dd5 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/activities/MutableActivityManager.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/activities/MutableActivityManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -31,7 +31,6 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.activities.ActivityEvent;
import org.eclipse.ui.activities.ActivityManagerEvent;
@@ -45,12 +44,9 @@ import org.eclipse.ui.activities.IIdentifier;
import org.eclipse.ui.activities.IMutableActivityManager;
import org.eclipse.ui.activities.ITriggerPointAdvisor;
import org.eclipse.ui.activities.IdentifierEvent;
-import org.eclipse.ui.internal.WorkbenchPlugin;
-import org.eclipse.ui.internal.misc.Policy;
import org.eclipse.ui.progress.UIJob;
import org.eclipse.ui.services.IEvaluationReference;
import org.eclipse.ui.services.IEvaluationService;
-import org.eclipse.ui.statushandlers.StatusManager;
/**
* An activity registry that may be altered.
@@ -59,10 +55,6 @@ import org.eclipse.ui.statushandlers.StatusManager;
*/
public final class MutableActivityManager extends AbstractActivityManager
implements IMutableActivityManager, Cloneable {
- private static final boolean DEBUG = Policy.DEBUG_UI_GLOBAL;
-
- private static final int MAX_ERRORS = 5;
- private static int reportErrors = 0;
private Map activitiesById = new HashMap();
@@ -140,8 +132,7 @@ public final class MutableActivityManager extends AbstractActivityManager
readRegistry(true);
}
- public IActivity getActivity(String activityId) {
- checkThread();
+ synchronized public IActivity getActivity(String activityId) {
if (activityId == null) {
throw new NullPointerException();
}
@@ -157,8 +148,7 @@ public final class MutableActivityManager extends AbstractActivityManager
return activity;
}
- public ICategory getCategory(String categoryId) {
- checkThread();
+ synchronized public ICategory getCategory(String categoryId) {
if (categoryId == null) {
throw new NullPointerException();
}
@@ -174,23 +164,19 @@ public final class MutableActivityManager extends AbstractActivityManager
return category;
}
- public Set getDefinedActivityIds() {
- checkThread();
+ synchronized public Set getDefinedActivityIds() {
return Collections.unmodifiableSet(definedActivityIds);
}
- public Set getDefinedCategoryIds() {
- checkThread();
+ synchronized public Set getDefinedCategoryIds() {
return Collections.unmodifiableSet(definedCategoryIds);
}
- public Set getEnabledActivityIds() {
- checkThread();
+ synchronized public Set getEnabledActivityIds() {
return Collections.unmodifiableSet(enabledActivityIds);
}
- public IIdentifier getIdentifier(String identifierId) {
- checkThread();
+ synchronized public IIdentifier getIdentifier(String identifierId) {
if (identifierId == null) {
throw new NullPointerException();
}
@@ -536,8 +522,7 @@ public final class MutableActivityManager extends AbstractActivityManager
}
}
- public void setEnabledActivityIds(Set enabledActivityIds) {
- checkThread();
+ synchronized public void setEnabledActivityIds(Set enabledActivityIds) {
enabledActivityIds = new HashSet(enabledActivityIds);
Set requiredActivityIds = new HashSet(enabledActivityIds);
getRequiredActivityIds(enabledActivityIds, requiredActivityIds);
@@ -920,8 +905,7 @@ public final class MutableActivityManager extends AbstractActivityManager
/* (non-Javadoc)
* @see java.lang.Object#clone()
*/
- public Object clone() {
- checkThread();
+ synchronized public Object clone() {
MutableActivityManager clone = new MutableActivityManager(advisor, activityRegistry);
clone.setEnabledActivityIds(getEnabledActivityIds());
return clone;
@@ -981,24 +965,4 @@ public final class MutableActivityManager extends AbstractActivityManager
return deferredIdentifierJob;
}
- private static final String ERR_MSG = "Invalid Thread Access to Activity Manager"; //$NON-NLS-1$
-
- private void checkThread() {
- if (!DEBUG) {
- return;
- }
- if (reportErrors >= MAX_ERRORS) {
- return;
- }
- if (PlatformUI.getWorkbench().isStarting()) {
- return;
- }
- boolean nonUiThread = (null == Display.getCurrent());
- if (nonUiThread) {
- reportErrors++;
- StatusManager.getManager().handle(
- new Status(IStatus.ERROR, WorkbenchPlugin.PI_WORKBENCH, ERR_MSG, new Exception(
- ERR_MSG)), StatusManager.LOG);
- }
- }
}