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.
Open Tools/Options/Action/System/ and select Customize Bean Try to paste it to a toolbar or menu, you will receive NPE in CookieAction: java.lang.NullPointerException at org.openide.util.actions.CookieAction.enable(CookieAction.java:105) at org.openide.util.actions.NodeAction.isEnabled(NodeAction.java:119) at org.openide.awt.Actions$MenuBridge.updateState(Actions.java:472) at org.openide.awt.Actions.connect(Actions.java:77) at org.openide.awt.Actions$MenuItem.<init>(Actions.java:732) at org.openide.util.actions.CallableSystemAction.getMenuPresenter(CallableSystemAction.java:35) at org.openide.awt.MenuBar$MenuFolder$LazyMenu.updatePopup(MenuBar.java:460) at org.openide.awt.MenuBar$MenuFolder$LazyMenu.getPopupMenu(MenuBar.java:436) at org.openide.awt.JMenuPlus.setPopupMenuVisible(JMenuPlus.java:52) at javax.swing.JPopupMenu.menuSelectionChanged(JPopupMenu.java:1135) at javax.swing.MenuSelectionManager.setSelectedPath(MenuSelectionManager.java:78) at javax.swing.MenuSelectionManager.clearSelectedPath(MenuSelectionManager.java:110) at org.netbeans.core.windows.RegistryImpl.cancelMenu(RegistryImpl.java:302) at org.netbeans.core.windows.RegistryImpl.topComponentActivated(RegistryImpl.java:192) at org.netbeans.core.windows.WindowManagerImpl.activateComponent(WindowManagerImpl.java:700) at org.netbeans.core.windows.frames.DefaultContainerImpl.doActivateComponent(DefaultContainerImpl.java:558) at org.netbeans.core.windows.frames.DefaultContainerImpl.reactivateSelectedComponent(DefaultContainerImpl.java:732) at org.netbeans.core.windows.frames.DefaultContainerImpl$2.run(DefaultContainerImpl.java:891) at org.netbeans.core.windows.frames.DefaultContainerImpl$4.run(DefaultContainerImpl.java:906) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:154) at java.awt.EventQueue.dispatchEvent(EventQueue.java:337) [catch] at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:131) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:98) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) at java.awt.EventDispatchThread.run(EventDispatchThread.java:85)
I believe it's caused by the fact that CookieAction.initialize() is not called during deserialization of the instance. 'listeners' field should be better init'ed in the constructor
Are you using CookieAction.java 1.19? Or 1.20? Next time give a build number or date please. 1.20 was supposed to fix similar problems (doEnable should indirectly call getProperty thus initialize()), but the line number corresponds to 1.20 (I guess), so I will look at it.
Trung's comment may be right, but Yarda please first confirm for me as a question of semantics: IMHO if a SCO.WriteReplace is deserialized, then later getProperty() is called on it, initialize() should still be called first, correct? Not sure I understand how this would work for SystemOption's that store values as SCO properties rather than getters and setters, however.
Jesse: I did not add build number, cause it is very easy to reproduce. To satisfy your request, I tried it in (Build 200111240954) and reproduced the problem. initialize: I doubt it is a problem with deserialization. After copying .instance file is created - thus no deserialization occurs.
Actually not so trivial to reproduce; you need to do things in a certain order, maybe have toolbars visible, etc.--to reproduce it is best to start with a clean user dir, do *nothing* else in that IDE session, run with full module set, open Options, expand IDE Settings | L&F | Actions | System (this is when dupes are made), right-click Customize Bean and select Copy, expand Toolbars and Data, right-click and the NPE occurs. The problem occurs due to finalization of RefreshAction (which happens twice under these particular circumstances and memory conditions). Listener should be moved to constructor in CookieAction in case this happens. Have fix, will commit tomorrow unless someone needs it earlier. BTW should probably be 3.3.1 candidate? I see no keywords to mark it as such.
fix should go into release33 branch, bug marked with 3.3.0_CANDIDATE keyword to make it a candidate for release330 branch, patch against release330 preferrably attached to the bug report to make it easier for people to review. Close the bug as FIXED.
Will attach patch. Actual commit to release33 tomorrow.
Created attachment 3580 [details] Proposed patch
committed Up-To-Date 1.20.2.1 openide/src/org/openide/util/actions/CookieAction.java
verified in trunk dev#200111270100
Really verified in the trunk?! I only fixed it in release33 branch.
Actually I missed your comment. However, I am not able to reproduce this in build #200111270100, while in dev#200111230723 without problems. I'll check this in 3.3 too.
verified in #200111280300 - 3.3 build
Fixed in release330: CookieAction.java 1.20.4.1
Resolved for 3.4.x or earlier, no new info since then -> closing.