Bug 293221 - [Memory View] NPE in AddMemoryRenderingActionDelegate
Summary: [Memory View] NPE in AddMemoryRenderingActionDelegate
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 3.4.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.6 M5   Edit
Assignee: Justin Kong CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2009-10-23 18:07 EDT by Samantha Chan CLA
Modified: 2010-01-15 14:57 EST (History)
2 users (show)

See Also:


Attachments
Patch #1 (2.83 KB, patch)
2009-12-29 18:16 EST, Justin Kong CLA
no flags Details | Diff
another approach (916 bytes, text/plain)
2010-01-11 12:59 EST, Samantha Chan CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Samantha Chan CLA 2009-10-23 18:07:09 EDT
No step to reproduce, found it in the log.

java.lang.NullPointerException
	at org.eclipse.debug.ui.actions.AddMemoryRenderingActionDelegate.updateAction(Unknown Source)
	at org.eclipse.debug.ui.actions.AddMemoryRenderingActionDelegate.access$5(Unknown Source)
	at org.eclipse.debug.ui.actions.AddMemoryRenderingActionDelegate$DebugContextListener.contextActivated(Unknown Source)
	at org.eclipse.debug.ui.actions.AddMemoryRenderingActionDelegate$DebugContextListener.debugContextChanged(Unknown Source)
	at org.eclipse.debug.internal.ui.contexts.DebugWindowContextService$1.run(Unknown Source)
	at org.eclipse.core.runtime.SafeRunner.run(Unknown Source)
	at org.eclipse.debug.internal.ui.contexts.DebugWindowContextService.notify(Unknown Source)
	at org.eclipse.debug.internal.ui.contexts.DebugWindowContextService.notify(Unknown Source)
	at org.eclipse.debug.internal.ui.contexts.DebugWindowContextService.debugContextChanged(Unknown Source)
	at org.eclipse.debug.ui.contexts.AbstractDebugContextProvider$1.run(Unknown Source)
	at org.eclipse.core.runtime.SafeRunner.run(Unknown Source)
	at org.eclipse.debug.ui.contexts.AbstractDebugContextProvider.fire(Unknown Source)
	at org.eclipse.debug.internal.ui.views.launch.LaunchView$ContextProvider.activate(Unknown Source)
	at org.eclipse.debug.internal.ui.views.launch.LaunchView.selectionChanged(Unknown Source)
	at org.eclipse.jface.viewers.Viewer$2.run(Unknown Source)
	at org.eclipse.core.runtime.SafeRunner.run(Unknown Source)
	at org.eclipse.core.runtime.Platform.run(Unknown Source)
	at org.eclipse.ui.internal.JFaceUtil$1.run(Unknown Source)
	at org.eclipse.jface.util.SafeRunnable.run(Unknown Source)
	at org.eclipse.jface.viewers.Viewer.fireSelectionChanged(Unknown Source)
	at org.eclipse.jface.viewers.StructuredViewer.updateSelection(Unknown Source)
	at org.eclipse.jface.viewers.StructuredViewer.handleSelect(Unknown Source)
	at org.eclipse.jface.viewers.StructuredViewer$4.widgetSelected(Unknown Source)
	at org.eclipse.jface.util.OpenStrategy.fireSelectionEvent(Unknown Source)
	at org.eclipse.jface.util.OpenStrategy.access$3(Unknown Source)
	at org.eclipse.jface.util.OpenStrategy$1.handleEvent(Unknown Source)
	at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
	at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Unknown Source)
	at org.eclipse.ui.internal.Workbench.runUI(Unknown Source)
	at org.eclipse.ui.internal.Workbench.access$4(Unknown Source)
	at org.eclipse.ui.internal.Workbench$5.run(Unknown Source)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Unknown Source)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Unknown Source)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(Unknown Source)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(Unknown Source)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(Unknown Source)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(Unknown Source)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(Unknown Source)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(Unknown Source)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(Unknown Source)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Unknown Source)
	at org.eclipse.equinox.launcher.Main.basicRun(Unknown Source)
	at org.eclipse.equinox.launcher.Main.run(Unknown Source)
	at org.eclipse.equinox.launcher.Main.main(Unknown Source)
Comment 1 Samantha Chan CLA 2009-10-30 16:10:24 EDT
Justin, please investigate.
Comment 2 Darin Wright CLA 2009-12-04 12:51:52 EST
Changing milestone to 3.6. Justin or Sam can update as appropriate.
Comment 3 Justin Kong CLA 2009-12-29 18:16:17 EST
Created attachment 155119 [details]
Patch #1

Was unable to reproduce the NPE, but found the possible cause for this error. In updateAction, there's a possibility that action is null. If it is, this could cause the NPE to occur.

Most of the calls to updateAction are preceded by a call to bindAction, which does a check to see if the action is null. Thus, instead of having the check in bindAction, I decided to check if the action is null before bindAction and updateAction are called.
Comment 4 Samantha Chan CLA 2010-01-05 11:45:20 EST
Thank you for patches. I will review.
Comment 5 Samantha Chan CLA 2010-01-11 12:56:52 EST
Justin, what are the case where the action can be null?
Why do we not want to check for null in update actions, but rather guard the calls with a null check?  

Wouldn't it be simpler if we simply add the null check in updateAction?
bindAction have a null check and should be safe.
Comment 6 Samantha Chan CLA 2010-01-11 12:59:41 EST
Created attachment 155773 [details]
another approach
Comment 7 Justin Kong CLA 2010-01-13 16:50:59 EST
The changes I proposed are a bit more complex, but I chose to do it this way as opposed to adding the null check in updateAction, as bindAction already does a null check. Thus, I thought it would be redundant if we could enter both methods, knowing fully beforehand that we would return from them immediately as the action is null. And since bindAction and updateAction are both called hand-in-hand, I decided to remove the check from bindAction and just have it checked before we enter either method.
Comment 8 Samantha Chan CLA 2010-01-15 14:57:11 EST
applied Justin's patch
Comment 9 Samantha Chan CLA 2010-01-15 14:57:30 EST
verified