Project: JDT
Bug 140548 [junit] NPE when opening history menu after removing launch configuration
Reported: 2006-05-08 08:49:18 | Status: verified fixed

I20060505-1306 Steps: - run a JUnit Test - delete the launch configuration - open JUnit view history menu or click on the toolbar button The user can only get rid of the NPEs by restarting Eclipse or by clicking on the history toolbar button, confirming the error dialog, and then removing the launches from the list. The bug is in TestRunSession: public String getTestRunName() { return fLaunch.getLaunchConfiguration().getName(); } Since the launch configuration can become null, we should store the original name. java.lang.NullPointerException at org.eclipse.jdt.internal.junit.model.TestRunSession.getTestRunName(TestRunSession.java:121) at org.eclipse.jdt.internal.junit.ui.TestRunnerViewPart$RunnerViewHistory.getText(TestRunnerViewPart.java:359) at org.eclipse.jdt.internal.ui.viewsupport.HistoryDropDownAction$HistoryAction.<init>(HistoryDropDownAction.java:36) at org.eclipse.jdt.internal.ui.viewsupport.HistoryDropDownAction$HistoryMenuCreator.addEntryMenuItems(HistoryDropDownAction.java:91) at org.eclipse.jdt.internal.ui.viewsupport.HistoryDropDownAction$HistoryMenuCreator.getMenu(HistoryDropDownAction.java:64) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:514) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:488) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:441) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:928) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3348) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2968) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1914) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1878) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:419) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:95) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:78) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:68) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336) at org.eclipse.core.launcher.Main.basicRun(Main.java:280) at org.eclipse.core.launcher.Main.run(Main.java:977) at org.eclipse.core.launcher.Main.main(Main.java:952) !ENTRY org.eclipse.ui 4 4 2006-05-08 10:03:04.215 !MESSAGE Unhandled event loop exception !ENTRY org.eclipse.ui 4 0 2006-05-08 10:03:04.215 !MESSAGE java.lang.NullPointerException !STACK 0 java.lang.NullPointerException at org.eclipse.jdt.internal.junit.model.TestRunSession.getTestRunName(TestRunSession.java:121) at org.eclipse.jdt.internal.junit.ui.TestRunnerViewPart$RunnerViewHistory.getText(TestRunnerViewPart.java:359) at org.eclipse.jdt.internal.ui.viewsupport.HistoryDropDownAction$HistoryAction.<init>(HistoryDropDownAction.java:36) at org.eclipse.jdt.internal.ui.viewsupport.HistoryDropDownAction$HistoryMenuCreator.addEntryMenuItems(HistoryDropDownAction.java:91) at org.eclipse.jdt.internal.ui.viewsupport.HistoryDropDownAction$HistoryMenuCreator.getMenu(HistoryDropDownAction.java:64) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:514) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:488) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:441) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:928) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3348) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2968) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1914) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1878) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:419) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:95) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:78) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:68) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336) at org.eclipse.core.launcher.Main.basicRun(Main.java:280) at org.eclipse.core.launcher.Main.run(Main.java:977) at org.eclipse.core.launcher.Main.main(Main.java:952)

Files changed in fix:
org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/model/TestRunSession.java org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/model/TestRunSession.java