diff options
author | Mike Rennie | 2013-09-06 16:20:47 +0000 |
---|---|---|
committer | Mike Rennie | 2013-09-06 16:21:11 +0000 |
commit | 535f3fc6e553ec5c9e0afd0e14856570088f6c40 (patch) | |
tree | b86df5a8053f9ec734ee9a91b4f0160487f200d8 | |
parent | 70064b52b9bcd2316ef058d5344933115d457752 (diff) | |
download | eclipse.platform.debug-I20130917-0800.tar.gz eclipse.platform.debug-I20130917-0800.tar.xz eclipse.platform.debug-I20130917-0800.zip |
Bug 416691 - NPE for Launch without launch configurationI20131001-0800I20130924-1130I20130924-0800I20130918-2000I20130918-0800I20130917-2000I20130917-0800I20130916-2330I20130916-2000I20130916-0900I20130915-2000I20130914-1900I20130914-1500I20130913-2000I20130912-2000I20130911-2000I20130910-2000I20130910-0800I20130909-2000I20130908-2000I20130906-2000
Change-Id: I6d7e7272c6e5fa774ca6e1efdf480e8593c65ef6
2 files changed, 35 insertions, 10 deletions
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/LaunchConfigurationTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/LaunchConfigurationTests.java index 707ac8465..877f03d5a 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/LaunchConfigurationTests.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/LaunchConfigurationTests.java @@ -50,6 +50,7 @@ import org.eclipse.debug.core.ILaunchConfigurationListener; import org.eclipse.debug.core.ILaunchConfigurationType; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.ILaunchManager; +import org.eclipse.debug.core.Launch; import org.eclipse.debug.internal.core.LaunchConfiguration; import org.eclipse.debug.internal.core.LaunchManager; import org.eclipse.debug.tests.TestsPlugin; @@ -57,6 +58,7 @@ import org.eclipse.debug.ui.DebugUITools; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; +import org.osgi.framework.Bundle; /** * Tests for launch configurations @@ -1517,7 +1519,29 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau } /** + * Tests that a launch created without a backing + * {@link ILaunchConfiguration} does not cause {@link NullPointerException}s + * + * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=416691 + * @throws Exception + * @since 3.9.0 + */ + public void testNullLaunchConfigurationInLaunch() throws Exception { + Launch l = new Launch(null, ILaunchManager.RUN_MODE, null); + LaunchManager lm = (LaunchManager) DebugPlugin.getDefault().getLaunchManager(); + // find the external tools UI bundle and make sure it is started + Bundle b = Platform.getBundle("org.eclipse.ui.externaltools"); //$NON-NLS-1$ + assertNotNull("Must have found the external tools bundle", b); //$NON-NLS-1$ + if (b.getState() != Bundle.ACTIVE) { + b.start(); + } + // no NPE should be logged + lm.addLaunch(l); + } + + /** * Proxy to set resource paths, allowing invalid resource paths to be set + * * @param resources * @since 3.9.0 */ diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolsPlugin.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolsPlugin.java index 3cafc26f2..76fb4d79b 100644 --- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolsPlugin.java +++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolsPlugin.java @@ -265,18 +265,19 @@ public final class ExternalToolsPlugin extends AbstractUIPlugin implements @Override public void launchAdded(ILaunch launch) { ILaunchConfiguration launchConfiguration = launch.getLaunchConfiguration(); - try { - ILaunchConfigurationType launchConfigurationType = launchConfiguration.getType(); - if (launchConfigurationType.getIdentifier().equals( - IExternalToolConstants.ID_PROGRAM_LAUNCH_CONFIGURATION_TYPE)) { - if (fWindowListener == null) { - fWindowListener = new ProgramLaunchWindowListener(); - PlatformUI.getWorkbench().addWindowListener(fWindowListener); - launchManager.removeLaunchListener(this); + if (launchConfiguration != null) { + try { + ILaunchConfigurationType launchConfigurationType = launchConfiguration.getType(); + if (launchConfigurationType.getIdentifier().equals(IExternalToolConstants.ID_PROGRAM_LAUNCH_CONFIGURATION_TYPE)) { + if (fWindowListener == null) { + fWindowListener = new ProgramLaunchWindowListener(); + PlatformUI.getWorkbench().addWindowListener(fWindowListener); + launchManager.removeLaunchListener(this); + } } + } catch (CoreException e) { + log(e); } - } catch (CoreException e) { - log(e); } } |