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

Bug 413329

Summary: NPE in CustomizePerspectiveDialog in createMenuEntries
Product: [Eclipse Project] Platform Reporter: Hendrik Eeckhaut <hendrik>
Component: UIAssignee: Andrey Loskutov <loskutov>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, ignacio, jed.anderson, jgangemi, loskutov
Version: 4.3Keywords: helpwanted
Target Milestone: 4.5 M6   
Hardware: All   
OS: All   
See Also: https://git.eclipse.org/r/41387
https://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=681a940be7d8b5d62f2961cb856e65a6f01f853b
https://git.eclipse.org/r/45843
https://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=34f01a490d31a8591bf4a053d3be7192c1bb9972
Whiteboard:
Bug Depends on:    
Bug Blocks: 420956    

Description Hendrik Eeckhaut CLA 2013-07-19 10:13:25 EDT
When I try to open "Window > Customize Perspective", I see nothing. When I check the log I see:

java.lang.NullPointerException
	at org.eclipse.ui.internal.dialogs.CustomizePerspectiveDialog.createMenuEntries(CustomizePerspectiveDialog.java:3040)
	at org.eclipse.ui.internal.dialogs.CustomizePerspectiveDialog.createMenuEntries(CustomizePerspectiveDialog.java:3054)
	at org.eclipse.ui.internal.dialogs.CustomizePerspectiveDialog.createMenuStructure(CustomizePerspectiveDialog.java:2945)
	at org.eclipse.ui.internal.dialogs.CustomizePerspectiveDialog.loadMenuAndToolbarStructure(CustomizePerspectiveDialog.java:2699)
	at org.eclipse.ui.internal.dialogs.CustomizePerspectiveDialog.<init>(CustomizePerspectiveDialog.java:1484)
	at org.eclipse.ui.internal.WorkbenchWindow.createCustomizePerspectiveDialog(WorkbenchWindow.java:2723)
	at org.eclipse.ui.internal.WorkbenchPage.editActionSets(WorkbenchPage.java:1855)
	at org.eclipse.ui.internal.handlers.EditActionSetsHandler.execute(EditActionSetsHandler.java:41)
	at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:290)
	at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:90)
	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:597)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:243)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:224)
	at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:132)
	at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:167)
	at org.eclipse.core.commands.Command.executeWithChecks(Command.java:499)
	at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
	at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:213)
	at org.eclipse.ui.internal.handlers.LegacyHandlerService.executeCommand(LegacyHandlerService.java:420)
	at org.eclipse.ui.internal.actions.CommandAction.runWithEvent(CommandAction.java:157)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
	at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
	at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1392)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3742)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3363)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1113)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:997)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:138)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:610)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:567)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
	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:597)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1426)
Comment 1 Paul Webster CLA 2013-07-22 14:50:01 EDT
What's your build id for your eclipse?  (In the eclipse/configuration/config.ini file or in the Help>About dialog)

Did you pick up an EPP from www.eclipse.org/downloads ?

PW
Comment 2 Hendrik Eeckhaut CLA 2013-07-22 17:13:30 EDT
Hi Paul,

my installation was not downloaded directly from eclipse.org. It was installed via Genuitec's SDC (Based on: Eclipse 4.3.0 IDE for Java and DSL Developers). I'm not sure this is exactly the same version.

I just checked and have the same behaviour on Mac.

Build id: I20130605-2000

Hendrik.
Comment 3 Paul Webster CLA 2013-07-23 13:53:33 EDT
Looks like we don't check for null after 

if (menuItem instanceof MMenu) {
	contributionItem = menuMngrRenderer.getManager((MMenu) menuItem);
} else {
	contributionItem = menuMngrRenderer.getContribution(menuItem);
}


PW
Comment 4 Jed Anderson CLA 2013-10-25 19:30:37 EDT
Paul, is there a workaround we could use to dodge this missing null check while still filtering the org.eclipse.epp.mpc.ui.command.showMarketplaceWizard item?

Maybe we could supply our own registration for that id but not have it be visible?  Not being an e4 expert, I'm looking for a little guidance.
Comment 5 Paul Webster CLA 2013-10-30 10:45:21 EDT
(In reply to Jed Anderson from comment #4)
> Paul, is there a workaround we could use to dodge this missing null check
> while still filtering the
> org.eclipse.epp.mpc.ui.command.showMarketplaceWizard item?

How are you filtering that item?  Setting its visibility to false?  TBR?  Or using activities/capabilities?

PW
Comment 6 Jed Anderson CLA 2013-11-07 23:59:27 EST
What we found is that if we specified the following, we didn't see the NPE:

element.setToBeRendered(false);
element.setVisible(false);
element.setParent(null);
element.setOnTop(false);

I'm not convinced all of this is necessary, but it does appear to work around the issue.
Comment 7 Paul Webster CLA 2013-11-08 09:55:36 EST
(In reply to Jed Anderson from comment #6)
> What we found is that if we specified the following, we didn't see the NPE:
> 
> element.setToBeRendered(false);
> element.setVisible(false);

Using setToBeRendered(false) will remove the contribution item that is linked with the element.  setVisible(false) removes the widget for an item.

> element.setParent(null);

This flat out removes it from the model, so it is orphaned.

PW
Comment 8 Noopur Gupta CLA 2015-01-29 01:25:59 EST
*** Bug 407453 has been marked as a duplicate of this bug. ***
Comment 9 Andrey Loskutov CLA 2015-02-08 15:29:20 EST
Proposed fix: https://git.eclipse.org/r/41387

It is a simple guard for misconfigured contributions (they will be not shown in CPD).
Comment 10 Eclipse Genie CLA 2015-02-09 08:41:29 EST
New Gerrit change created: https://git.eclipse.org/r/41387
Comment 12 Dani Megert CLA 2015-02-19 09:31:36 EST
.
Comment 13 Andrey Loskutov CLA 2015-03-19 18:15:31 EDT
Verified through meditation over the code in I20150318-2000
Comment 14 Eclipse Genie CLA 2015-04-15 04:15:19 EDT
New Gerrit change created: https://git.eclipse.org/r/45843