This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 254719 - Prevent NPE when removing LocalTerminalAction from the /Terminal/Actions folder
Summary: Prevent NPE when removing LocalTerminalAction from the /Terminal/Actions folder
Status: RESOLVED FIXED
Alias: None
Product: cnd
Classification: Unclassified
Component: Terminalemulator (show other bugs)
Version: 8.0.2
Hardware: All All
: P3 normal (vote)
Assignee: ilia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-08-25 14:34 UTC by jmborer
Modified: 2015-08-28 01:24 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jmborer 2015-08-25 14:34:12 UTC
You can easily embed the Terminal module in an NBP app. If you don't want to use a LocalTerminalAction, it is easy to remove it from the /Terminal/Actions folder in a layer.xml file.

However, this leads to a NPE in the TerminalContainerTopComponent.componentOpened(), because TerminalSettingsAction has no Action.NAME property set. 

More precisely:

    @Override
    public void componentOpened() {
        JComponent selectedTerminal = getIOContainer().getSelected();
        if (selectedTerminal == null && (this.getClientProperty(AUTO_OPEN_LOCAL_PROPERTY) != Boolean.FALSE)) {
            for (Action action : getToolbarActions()) {
                if (action.getValue(Action.NAME).toString().startsWith(LOCAL_TERMINAL_PREFIX)
                        && action.isEnabled()) {
                    action.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, SILENT_MODE_COMMAND));
                    break;
                }
            }
        }
    }

where action.getValue(Action.NAME) returns null for TerminalSettingsAction.

Two solutions:
1) check for null in the code above TerminalContainerTopComponent.componentOpened()
2) Assign a Action.NAME property to the TerminalSettingsAction in its constructor by using super class AbstractAction(name) call.
Comment 1 ilia 2015-08-25 15:55:59 UTC
Stacktrace:

java.lang.NullPointerException
	at org.netbeans.modules.dlight.terminal.ui.TerminalContainerTopComponent.componentOpened(TerminalContainerTopComponent.java:266)
[catch] at org.openide.windows.WindowManager.componentOpenNotify(WindowManager.java:307)
	at org.netbeans.core.windows.WindowManagerImpl.notifyTopComponentOpened(WindowManagerImpl.java:1149)
	at org.netbeans.core.windows.Central.addModeOpenedTopComponent(Central.java:798)
	at org.netbeans.core.windows.ModeImpl.addOpenedTopComponent(ModeImpl.java:354)
	at org.netbeans.core.windows.WindowManagerImpl.topComponentOpenAtTabPosition(WindowManagerImpl.java:1261)
	at org.netbeans.core.windows.WindowManagerImpl.topComponentOpen(WindowManagerImpl.java:1226)
	at org.openide.windows.TopComponent.open(TopComponent.java:497)
	at org.openide.windows.TopComponent.open(TopComponent.java:477)
	at org.netbeans.modules.dlight.terminal.action.ShowTerminalAction.actionPerformed(ShowTerminalAction.java:63)
	at org.openide.awt.AlwaysEnabledAction$1.run(AlwaysEnabledAction.java:199)
	at org.openide.util.actions.ActionInvoker$1.run(ActionInvoker.java:95)
	at org.openide.util.actions.ActionInvoker.doPerformAction(ActionInvoker.java:116)
	at org.openide.util.actions.ActionInvoker.invokeAction(ActionInvoker.java:99)
	at org.openide.awt.AlwaysEnabledAction.actionPerformed(AlwaysEnabledAction.java:202)
	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
	at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
	at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
	at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
	at javax.swing.AbstractButton.doClick(AbstractButton.java:376)
	at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:833)
	at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:877)
	at java.awt.Component.processMouseEvent(Component.java:6505)
	at javax.swing.JComponent.processMouseEvent(JComponent.java:3320)
	at java.awt.Component.processEvent(Component.java:6270)
	at java.awt.Container.processEvent(Container.java:2229)
	at java.awt.Component.dispatchEventImpl(Component.java:4861)
	at java.awt.Container.dispatchEventImpl(Container.java:2287)
	at java.awt.Component.dispatchEvent(Component.java:4687)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
	at java.awt.Container.dispatchEventImpl(Container.java:2273)
	at java.awt.Window.dispatchEventImpl(Window.java:2719)
	at java.awt.Component.dispatchEvent(Component.java:4687)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
	at java.awt.EventQueue.access$200(EventQueue.java:103)
	at java.awt.EventQueue$3.run(EventQueue.java:694)
	at java.awt.EventQueue$3.run(EventQueue.java:692)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
	at java.awt.EventQueue$4.run(EventQueue.java:708)
	at java.awt.EventQueue$4.run(EventQueue.java:706)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
	at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:159)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Comment 2 ilia 2015-08-25 16:07:51 UTC
Thanks for suggested solutions.

Fixed in:
  http://hg.netbeans.org/cnd-main/rev/910aece1a4e9
Comment 3 Quality Engineering 2015-08-26 01:24:01 UTC
Integrated into 'main-silver', will be available in build *201508260002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/910aece1a4e9
User: Ilia Gromov <ilia@netbeans.org>
Log: fixed Bug #254719 - Prevent NPE when removing LocalTerminalAction from the /Terminal/Actions folder
Comment 4 Quality Engineering 2015-08-28 01:24:44 UTC
Integrated into 'main-silver', will be available in build *201508280002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/b5d0dbb06803
User: Ilia Gromov <ilia@netbeans.org>
Log: additional fix for Bug #254719 - Prevent NPE when removing LocalTerminalAction from the /Terminal/Actions folder
 - i18n