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.
CookieAction's innerclasses CookieChangeListener and CookieDelegateAction attach NodeListener to selected nodes. Because CookieDelegateAction attaches the listener as a weak listener, CookieDelegateAction can be disposed at the same moment as CookieAction. However, the weak listener is kept attached to the nodes. (The weak listener has its source set to null because it can be attached to several sources at a moment). I am adding finalizer to CookieDelegateAction which detaches the weak listener easily. Similar case is the CookieChangeListener, but it does not attach weak listener (it attaches itself as the listener) and thus cannot be at all disposed and keeps listening on the nodes. I am changing the listener to be wrapped as weak as well. And then I am also adding the same finalizer as in the case of CookieDelegateAction. Both these fixes are verified by the introduced test, added to the CookieAction2Test class. If I run the test on the original CookieAction without finalizers, the listeners are verified kept attached. With the fix the test verifies that the listeners go away.
Checking in src/org/openide/util/actions/CookieAction.java; /cvs/openide/src/org/openide/util/actions/CookieAction.java,v <-- CookieAction.java new revision: 1.27; previous revision: 1.26 done Checking in test/unit/src/org/openide/util/actions/CookieAction2Test.java; /cvs/openide/test/unit/src/org/openide/util/actions/CookieAction2Test.java,v <-- CookieAction2Test.java new revision: 1.3; previous revision: 1.2 done
Verified.