Bug 480076: Excessive threads created (more than 30,000) for some tests, on some...
authorMarkus Keller <markus_keller@ch.ibm.com>
Wed, 18 Nov 2015 16:14:19 +0000 (17:14 +0100)
committerMarkus Keller <markus_keller@ch.ibm.com>
Wed, 13 Jan 2016 12:56:07 +0000 (13:56 +0100)
bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/activities/MutableActivityManager.java

index 58b3044..c4dc1fb 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 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
@@ -501,7 +501,7 @@ public final class MutableActivityManager extends AbstractActivityManager
     }
 
        private void clearExpressions() {
-               IEvaluationService evaluationService = (IEvaluationService) PlatformUI
+               IEvaluationService evaluationService = PlatformUI
                                .getWorkbench().getService(IEvaluationService.class);
                Iterator i = refsByActivityDefinition.values().iterator();
                while (i.hasNext()) {
@@ -719,7 +719,7 @@ public final class MutableActivityManager extends AbstractActivityManager
         // enabledWhen comes into play
         IEvaluationReference ref = (IEvaluationReference) refsByActivityDefinition
                                .get(activityDefinition);
-               IEvaluationService evaluationService = (IEvaluationService) PlatformUI
+               IEvaluationService evaluationService = PlatformUI
                                .getWorkbench().getService(IEvaluationService.class);
                boolean newRef = false;
                if (activityDefinition != null && evaluationService!=null) {
@@ -929,13 +929,11 @@ public final class MutableActivityManager extends AbstractActivityManager
      */
     private Job getUpdateJob() {
         if (deferredIdentifierJob == null) {
-            deferredIdentifierJob = new Job("Identifier Update Job") { //$NON-NLS-1$
-
-                /* (non-Javadoc)
-                 * @see org.eclipse.core.internal.jobs.InternalJob#run(org.eclipse.core.runtime.IProgressMonitor)
-                 */
+                       deferredIdentifierJob = new Job("Activity Identifier Update") { //$NON-NLS-1$
                 @Override
                                protected IStatus run(IProgressMonitor monitor) {
+                                       final Map identifierEventsByIdentifierId = new HashMap();
+
                     while (!deferredIdentifiers.isEmpty()) {
                         Identifier identifier = (Identifier) deferredIdentifiers.remove(0);
                         Set activityIds = new HashSet();
@@ -953,21 +951,20 @@ public final class MutableActivityManager extends AbstractActivityManager
                         if (activityIdsChanged) {
                             IdentifierEvent identifierEvent = new IdentifierEvent(identifier, activityIdsChanged,
                                     false);
-                            final Map identifierEventsByIdentifierId = new HashMap(1);
                             identifierEventsByIdentifierId.put(identifier.getId(),
                                     identifierEvent);
-                            UIJob notifyJob = new UIJob("Identifier Update Job") { //$NON-NLS-1$
-
-                                                               @Override
-                                                               public IStatus runInUIThread(
-                                                                               IProgressMonitor monitor) {
-                                                                       notifyIdentifiers(identifierEventsByIdentifierId);
-                                                                       return Status.OK_STATUS;
-                                                               }
-                            };
-                            notifyJob.setSystem(true);
-                            notifyJob.schedule();
-                        }
+                                               }
+                                       }
+                                       if (!identifierEventsByIdentifierId.isEmpty()) {
+                                               UIJob notifyJob = new UIJob("Activity Identifier Update UI") { //$NON-NLS-1$
+                                                       @Override
+                                                       public IStatus runInUIThread(IProgressMonitor monitor) {
+                                                               notifyIdentifiers(identifierEventsByIdentifierId);
+                                                               return Status.OK_STATUS;
+                                                       }
+                                               };
+                                               notifyJob.setSystem(true);
+                                               notifyJob.schedule();
                     }
                     return Status.OK_STATUS;
                 }