Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 273498

Summary: Launch history generation could be more robust
Product: [Eclipse Project] Platform Reporter: Remy Suen <remy.suen>
Component: DebugAssignee: Michael Rennie <Michael_Rennie>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: darin.eclipse, Michael_Rennie
Version: 3.5Flags: darin.eclipse: review+
Target Milestone: 3.5 RC1   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Malformed launchConfigurationHistory.xml
none
proposed fix none

Description Remy Suen CLA 2009-04-23 15:03:52 EDT
Build id: I20090414-0800

My Eclipse crashed and when I restarted it, I noticed that my launch config dropdown was empty. I thought I hit bug 268669 but it seems my launch configurations were still there despite the fact that my history was lost. From inspecting the log, I found the following...

!ENTRY org.eclipse.jdt.launching 4 4 2009-04-22 14:06:06.801
!MESSAGE Failed to retrieve default libraries for /home/rcjsuen/j9-f1.1
!SESSION 2009-04-23 14:55:30.929 -----------------------------------------------
eclipse.buildId=I20090414-0800
java.version=1.6.0_12
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=en_US
Command-line arguments:  -os linux -ws gtk -arch x86 -data /home/rcjsuen/ecf-workspace

!ENTRY org.eclipse.ui 4 4 2009-04-23 14:55:51.466
!MESSAGE Could not create action delegate for id: org.eclipse.debug.internal.ui.actions.RunHistoryMenuAction

!ENTRY org.eclipse.ui 4 4 2009-04-23 14:55:51.484
!MESSAGE Internal plug-in action delegate error on creation.
!STACK 0
java.lang.NullPointerException
        at org.eclipse.debug.internal.core.LaunchConfiguration.getSimpleName(LaunchConfiguration.java:184)
        at org.eclipse.debug.internal.core.LaunchConfiguration.<init>(LaunchConfiguration.java:226)
        at org.eclipse.debug.internal.core.LaunchManager.getLaunchConfiguration(LaunchManager.java:1359)
        at org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager.getLaunchConfigurations(LaunchConfigurationManager.java:600)
        at org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager.restoreHistory(LaunchConfigurationManager.java:565)
        at org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager.restoreLaunchHistory(LaunchConfigurationManager.java:543)
        at org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager.loadLaunchHistories(LaunchConfigurationManager.java:1072)
        at org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager.getLaunchHistory(LaunchConfigurationManager.java:1044)
        at org.eclipse.debug.ui.actions.AbstractLaunchHistoryAction.internalGetHistory(AbstractLaunchHistoryAction.java:403)
        at org.eclipse.debug.ui.actions.AbstractLaunchHistoryAction.getToolTip(AbstractLaunchHistoryAction.java:211)
        at org.eclipse.debug.ui.actions.AbstractLaunchHistoryAction.updateTooltip(AbstractLaunchHistoryAction.java:177)
        at org.eclipse.debug.ui.actions.AbstractLaunchHistoryAction.initialize(AbstractLaunchHistoryAction.java:147)
        at org.eclipse.debug.ui.actions.AbstractLaunchHistoryAction.selectionChanged(AbstractLaunchHistoryAction.java:371)
        at org.eclipse.ui.internal.PluginAction.refreshEnablement(PluginAction.java:206)
        at org.eclipse.ui.internal.PluginAction.createDelegate(PluginAction.java:126)
        at org.eclipse.ui.internal.PluginAction.selectionChanged(PluginAction.java:275)
        at org.eclipse.ui.internal.WWinPluginAction.refreshSelection(WWinPluginAction.java:275)
        at org.eclipse.ui.internal.WWinPluginAction.<init>(WWinPluginAction.java:121)
        at org.eclipse.ui.internal.WWinPluginPulldown.<init>(WWinPluginPulldown.java:188)
        at org.eclipse.ui.internal.ActionDescriptor.createAction(ActionDescriptor.java:269)
        at org.eclipse.ui.internal.ActionDescriptor.<init>(ActionDescriptor.java:176)
        at org.eclipse.ui.internal.PluginActionSetBuilder.createActionDescriptor(PluginActionSetBuilder.java:129)

Perhaps a SafeRunner or something could be used so one bad launch configuration doesn't cause the whole history to be lost? Speaking of bad launch configurations, I did have one launch configuration that had no name, it was the last one I launched before Eclipse crashed.
Comment 1 Remy Suen CLA 2009-04-23 15:05:20 EDT
(In reply to comment #0)
> Speaking of bad launch
> configurations, I did have one launch configuration that had no name, it was
> the last one I launched before Eclipse crashed.

To clarify, I'm pretty sure it had a name (I launched the main class via the context menu). But when I restarted the name was lost (but I could identify it by its main class).
Comment 2 Remy Suen CLA 2009-04-24 08:34:03 EDT
Created attachment 133109 [details]
Malformed launchConfigurationHistory.xml

Okay, maybe it didn't have a name after all. Restarting Eclipse doesn't help. Deleting the .metadata/.plugins/org.eclipse.debug.core/ folder doesn't help. Deleting .metadata/.plugins/org.eclipse.debug.ui/launchConfigurationHistory.xml did the trick.

As you can see from the file, there is a launch configuration with no name.
Comment 3 Remy Suen CLA 2009-04-24 17:54:07 EDT
I have filed bug 273656 for the buggy launch configuration generation code.
Comment 4 Michael Rennie CLA 2009-05-04 10:49:49 EDT
While the fix for bug 273656 will prevent Eclipse from creating configurations with no name, we should examine what we are doing during the history restore phase. As Remy mentioned we should not toss the whole history just because one (or more) configurations have errors / problems.
Comment 5 Michael Rennie CLA 2009-05-04 14:26:45 EDT
Created attachment 134283 [details]
proposed fix

Inspecting the code we are doing the correct thing, we prune any configuration that has errors / problems when trying to restore the history(s). Looking at the configuration code itself, we should be checking the name attribute when we load it from the memento, and throw an exception if the name is undefined.

The patch extends the support we had - which checked if attributes were present - with checking if the attributes actually have values.
Comment 6 Michael Rennie CLA 2009-05-04 14:31:58 EDT
applied patch to HEAD

please verify Darin W
Comment 7 Darin Wright CLA 2009-05-04 14:38:16 EDT
Verified.