Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 413535 - NPE in HandledContributionItem.canExecuteItem()
Summary: NPE in HandledContributionItem.canExecuteItem()
Status: CLOSED DUPLICATE of bug 411057
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.2.2   Edit
Hardware: PC Windows 7
: P3 major (vote)
Target Milestone: 4.2.2+   Edit
Assignee: Paul Webster CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 404312
Blocks:
  Show dependency tree
 
Reported: 2013-07-23 10:23 EDT by Paul Webster CLA
Modified: 2013-07-24 06:31 EDT (History)
8 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Webster CLA 2013-07-23 10:23:23 EDT
backport the fix to 4.2.2+

+++ This bug was initially created as a clone of Bug #404312 +++

The javadoc for HandledContributionItem.getContext() states that it should return "the closest context, or global context if none in the hierarchy", but when it its getContextForParent() method delegates to ModelServiceImpl.getContainingContext(), which delegates to ModelUtils.getContainingContext(), it simply returns null when it can't find one in the hierarchy.  This causes an NPE in HandledContributionItem.canExecuteItem(), which assumes a non-null context.  

See stack trace below:

Thread [main] (Suspended (breakpoint at line 194 in ModelUtils))	
	ModelUtils.getContainingContext(MApplicationElement) line: 194	
	ModelServiceImpl.getContainingContext(MUIElement) line: 276	
	HandledContributionItem.getContextForParent(MUIElement) line: 852	
	HandledContributionItem.getContext(MUIElement) line: 866	
	HandledContributionItem.canExecuteItem(Event) line: 822	
	HandledContributionItem.access$2(HandledContributionItem, Event) line: 817	
	HandledContributionItem$3.run() line: 216	
	SafeRunner.run(ISafeRunnable) line: 42	
	HandledContributionItem.updateItemEnablement() line: 243	
	HandledContributionItem$ToolItemUpdateTimer.run() line: 146	
	Display.runTimer(int) line: 4270	
	Display.messageProc(int, int, int, int) line: 3357	
	OS.DispatchMessageW(MSG) line: not available [native method]	
	OS.DispatchMessage(MSG) line: 2546	
	Display.readAndDispatch() line: 3756	
	PartRenderingEngine$9.run() line: 1029	
	Realm.runWithDefault(Realm, Runnable) line: 332	
	PartRenderingEngine.run(MApplicationElement, IEclipseContext) line: 923	
	E4Workbench.createAndRunUI(MApplicationElement) line: 86	
	Workbench$5.run() line: 588	
	Realm.runWithDefault(Realm, Runnable) line: 332	
	Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 543	
	PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 149	
	IDEApplication.start(IApplicationContext) line: 124	
	EclipseAppHandle.run(Object) line: 196	
	EclipseAppLauncher.runApplication(Object) line: 110	
	EclipseAppLauncher.start(Object) line: 79	
	EclipseStarter.run(Object) line: 353	
	EclipseStarter.run(String[], Runnable) line: 180	
	NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]	
	NativeMethodAccessorImpl.invoke(Object, Object[]) line: not available	
	DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: not available	
	Method.invoke(Object, Object...) line: not available	
	Main.invokeFramework(String[], URL[]) line: 629	
	Main.basicRun(String[]) line: 584	
	Main.run(String[]) line: 1438	
	Main.main(String[]) line: 1414
Comment 1 Dani Megert CLA 2013-07-24 04:25:19 EDT
Isn't this a duplicate of bug 411057? Or is the target milestone wrong?
Comment 2 Paul Webster CLA 2013-07-24 05:53:33 EDT

*** This bug has been marked as a duplicate of bug 411057 ***