diff options
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); } } |