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 243787 - Javadoc for ChildFactory.Detachable.removeNotify() needs warning about appropriate use cases
Summary: Javadoc for ChildFactory.Detachable.removeNotify() needs warning about approp...
Status: RESOLVED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Nodes (show other bugs)
Version: 8.0
Hardware: PC Mac OS X
: P3 normal with 1 vote (vote)
Assignee: Jan Peska
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-12 16:57 UTC by ebakke
Modified: 2014-07-19 10:19 UTC (History)
0 users

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 ebakke 2014-04-12 16:57:15 UTC
A doc bug here.

While debugging a memory leak in my platform application, I came to the realization that Children.Detachable.removeNotify() will only be called once the Children object is no longer strongly referenced, because the Nodes system uses the Active Reference Queue to figure out when to call removeNotify(). This makes Detachable.removeNotify() useless for detaching listeners, since any listener will keep the Children object referenced until removed, preventing removeNotify() from being called in the first place.

As it turns out, someone already realized this in the case of Children.removeNotify(), in https://netbeans.org/bugzilla/show_bug.cgi?id=99895 ("It seems I'll need to add a big fat warning into the removeNotify() javadoc.").

My suggestion is to add the same warning to Children.Detachable.removeNotify(), which is called under the same circumstances (via org.openide.nodes.SynchChildren). The warning from Children.removeNotify() currently reads: "Note that this is usually not the best place for unregistering listeners, etc., as listeners usually keep the child nodes in memory, preventing them from being collected, thus preventing this method to be called in the first place."
Comment 1 ebakke 2014-04-12 17:00:27 UTC
Sorry, I meant ChildFactory.Detachable, not Children.Detachable.
Comment 2 Jan Peska 2014-07-15 08:13:18 UTC
fix: http://hg.netbeans.org/core-main/rev/c89114f1d420
Comment 3 Quality Engineering 2014-07-19 10:19:07 UTC
Integrated into 'main-silver', will be available in build *201407190718* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/c89114f1d420
User: Jan Peska <JPESKA@netbeans.org>
Log: Issue #243787 - Javadoc for ChildFactory.Detachable.removeNotify() needs warning about appropriate use cases
Add warning to the javadoc about the behavior of the removeNotify method