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 58065

Summary: CookieAction's weak NodeListener instances are kept attached to nodes
Product: platform Reporter: Antonin Nebuzelsky <anebuzelsky>
Component: ActionsAssignee: Antonin Nebuzelsky <anebuzelsky>
Status: CLOSED FIXED    
Severity: blocker CC: issues, jtulach
Priority: P3 Keywords: PERFORMANCE
Version: 4.x   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:

Description Antonin Nebuzelsky 2005-04-19 20:43:54 UTC
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.
Comment 1 Antonin Nebuzelsky 2005-04-19 20:59:00 UTC
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
Comment 2 Jaromir Uhrik 2005-07-14 16:19:17 UTC
Verified.