Bug 545327 - [tests] Fix launch configuration leak in performance tests

Change-Id: Ibf942b60280969bab0e8d807ef83bfe0c9bf2981
Signed-off-by: Paul Pazderski <paul-eclipse@ppazderski.de>
diff --git a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/performance/PerfConsoleTests.java b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/performance/PerfConsoleTests.java
index c4a1a30..9e32b97 100644
--- a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/performance/PerfConsoleTests.java
+++ b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/performance/PerfConsoleTests.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- *  Copyright (c) 2000, 2015 IBM Corporation and others.
+ *  Copyright (c) 2000, 2019 IBM Corporation and others.
  *
  *  This program and the accompanying materials
  *  are made available under the terms of the Eclipse Public License 2.0
@@ -13,12 +13,12 @@
  *******************************************************************************/
 package org.eclipse.jdt.debug.tests.performance;
 
+import org.eclipse.debug.core.ILaunch;
 import org.eclipse.debug.core.ILaunchConfiguration;
 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
 import org.eclipse.debug.core.ILaunchManager;
 import org.eclipse.debug.internal.ui.DebugUIPlugin;
 import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants;
-import org.eclipse.debug.ui.DebugUITools;
 import org.eclipse.debug.ui.console.IConsole;
 import org.eclipse.debug.ui.console.IConsoleLineTrackerExtension;
 import org.eclipse.jdt.debug.testplugin.ConsoleLineTracker;
@@ -191,20 +191,18 @@
      * @throws Exception
      */
     protected void launchWorkingCopyAndWait(final ILaunchConfigurationWorkingCopy workingCopy) throws Exception {
-        Runnable runnable = new Runnable() {
-            @Override
-			public void run() {
-                DebugUITools.launch(workingCopy, ILaunchManager.RUN_MODE);
-            }
-        };
-
-        DebugUIPlugin.getStandardDisplay().asyncExec(runnable);
-
-        synchronized (fLock) {
-            if (!fStopped) {
-                fLock.wait(360000);
-            }
-        }
+		ILaunch launch = null;
+		try {
+			launch = workingCopy.launch(ILaunchManager.RUN_MODE, null);
+			synchronized (fLock) {
+				if (!fStopped) {
+					fLock.wait(360000);
+				}
+			}
+		} finally {
+			assertTrue("Test program took to long.", launch.isTerminated());
+			getLaunchManager().removeLaunch(launch);
+		}
     }
 
     /**