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 18017 - NPE when copying CustomizeBean action to menu || toolbar
Summary: NPE when copying CustomizeBean action to menu || toolbar
Status: CLOSED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Actions (show other bugs)
Version: 3.x
Hardware: PC Linux
: P2 blocker (vote)
Assignee: Jesse Glick
URL:
Keywords:
Depends on: 17911
Blocks:
  Show dependency tree
 
Reported: 2001-11-23 10:24 UTC by Jaroslav Tulach
Modified: 2008-12-22 15:49 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Proposed patch (1.55 KB, patch)
2001-11-26 16:48 UTC, Jesse Glick
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jaroslav Tulach 2001-11-23 10:24:20 UTC
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)
Comment 1 _ ttran 2001-11-23 10:57:41 UTC
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
Comment 2 Jesse Glick 2001-11-23 13:08:51 UTC
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.
Comment 3 Jesse Glick 2001-11-23 13:15:29 UTC
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.
Comment 4 Jaroslav Tulach 2001-11-24 14:00:25 UTC
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.
Comment 5 Jesse Glick 2001-11-26 10:49:23 UTC
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.
Comment 6 _ ttran 2001-11-26 16:12:42 UTC
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.
Comment 7 Jesse Glick 2001-11-26 16:47:26 UTC
Will attach patch. Actual commit to release33 tomorrow.
Comment 8 Jesse Glick 2001-11-26 16:48:21 UTC
Created attachment 3580 [details]
Proposed patch
Comment 9 Jesse Glick 2001-11-27 11:37:11 UTC
committed     Up-To-Date  1.20.2.1   
openide/src/org/openide/util/actions/CookieAction.java
Comment 10 Jan Zajicek 2001-11-27 12:49:35 UTC
verified in trunk dev#200111270100
Comment 11 Jesse Glick 2001-11-27 14:13:19 UTC
Really verified in the trunk?! I only fixed it in release33 branch.
Comment 12 Jan Zajicek 2001-11-27 15:04:10 UTC
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.
Comment 13 Jan Zajicek 2001-11-29 09:08:58 UTC
verified in #200111280300 - 3.3 build
Comment 14 Jesse Glick 2001-12-01 20:11:55 UTC
Fixed in release330: CookieAction.java 1.20.4.1
Comment 15 Quality Engineering 2003-07-01 16:21:32 UTC
Resolved for 3.4.x or earlier, no new info since then -> closing.