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 - CookieAction's weak NodeListener instances are kept attached to nodes
Summary: CookieAction's weak NodeListener instances are kept attached to nodes
Status: CLOSED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Actions (show other bugs)
Version: 4.x
Hardware: All All
: P3 blocker (vote)
Assignee: Antonin Nebuzelsky
URL:
Keywords: PERFORMANCE
Depends on:
Blocks:
 
Reported: 2005-04-19 20:43 UTC by Antonin Nebuzelsky
Modified: 2008-12-22 22:41 UTC (History)
2 users (show)

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 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.