[ https://issues.apache.org/jira/browse/NETBEANS-406?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eirik Bakke updated NETBEANS-406: --------------------------------- Fix Version/s: 10.0 > addPropertyChangeListener w/o matching removePropertyChangeListener > ------------------------------------------------------------------- > > Key: NETBEANS-406 > URL: https://issues.apache.org/jira/browse/NETBEANS-406 > Project: NetBeans > Issue Type: Bug > Components: editor - CSL (API & infrastructure), editor - > Painting & Printing > Affects Versions: 8.2, 9.0 > Environment: NetBeans 9.0 beta > (incubator-netbeans-release-205-on-20180202) on OpenJDK 64-Bit Server VM > 9.0.4.1+11, Mac OS 10.9.5 > Reporter: Eirik Bakke > Assignee: Matthias Bläsing > Priority: Minor > Labels: pull-request-available > Fix For: 10.0 > > Time Spent: 2h 40m > Remaining Estimate: 0h > > The following warning appears in the IDE log every now and then in 8.2 and > 9.0 beta: > > {code:java} > WARNING [org.openide.util.WeakListenerImpl]: Can't remove > java.beans.PropertyChangeListener using method > org.netbeans.modules.editor.NbEditorDocument.removePropertyChangeListener > from org.netbeans.modules.editor.NbEditorDocument@299b063c, > mimeType='text/x-editor-search', kitClass=null, length=9, version=15, > file=null{code} > > The warning above can be reproduced by opening a Java editor, closing all > editors, and then invoking a GC with by double-clicking the memory meter in > the "Performance" toolbar item. > This bug was previously discussed in Bugzilla at > [https://netbeans.org/bugzilla/show_bug.cgi?id=196323] . Not sure what > priority to put for this bug; it's a memory leak, but I'm not sure how big of > an impact it has. > *Analysis* > Storing a stacktrace in WeakListenerImpl.ListenerReference on creation and > then printing it on the failed removal shows the place where the problematic > listener is added: > {code:java} > java.lang.Exception > at > org.openide.util.WeakListenerImpl$ListenerReference.<init>(WeakListenerImpl.java:554) > at org.openide.util.WeakListenerImpl.<init>(WeakListenerImpl.java:109) > at org.openide.util.WeakListenerImpl.<init>(WeakListenerImpl.java:99) > at > org.openide.util.WeakListenerImpl$PropertyChange.<init>(WeakListenerImpl.java:187) > at org.openide.util.WeakListeners.propertyChange(WeakListeners.java:282) > at > org.netbeans.modules.editor.lib2.view.DocumentViewOp.checkSettingsInfo(DocumentViewOp.java:937) > at > org.netbeans.modules.editor.lib2.view.DocumentViewOp.checkViewsInited(DocumentViewOp.java:622) > at > org.netbeans.modules.editor.lib2.view.DocumentView.getPreferredSpan(DocumentView.java:251) > at > javax.swing.plaf.basic.BasicTextUI$RootView.getPreferredSpan(BasicTextUI.java:1353) > at javax.swing.plaf.basic.BasicTextUI.getPreferredSize(BasicTextUI.java:919) > at javax.swing.JComponent.getPreferredSize(JComponent.java:1662) > at javax.swing.JEditorPane.getPreferredSize(JEditorPane.java:1333) > at > org.netbeans.modules.editor.NbEditorUI$LayeredEditorPane.getPreferredSize(NbEditorUI.java:475){code} > The problem is on this line of DocumentViewOp: > {code:java} > o.n.modules.editor.lib2.view.DocumentUtilities.addPropertyChangeListener(doc, > WeakListeners.propertyChange(this, doc));{code} > The DocumentUtilities.addPropertyChangeListener is a special API for allowing > property change listeners to be attached to BaseDocument instances (see > Bugzilla [https://netbeans.org/bugzilla/show_bug.cgi?id=181073] ). Since it > doesn't actually add addPropertyChangeListener/removePropertyChangeListener > methods to BaseDocument, it doesn't work with WeakListeners. > As far as I can see, the only place that actually uses > DocumentUtilities.addPropertyChangeListener is the single line i > DocumentViewOp above. > I would propose adding a removedPropertyChangeListener method to BaseDocument > that delegates to DocumentUtilities.removePropertyChangeListener (or performs > the equivalent logic itself). This way the WeakListener will find the method > it expects when the listener is due to be removed, and the property change > events will still have the Document instance as the event source instead of > the delegate PropertyChangeSupport, as is probably desired. > An alternative is to make WeakListeners aware of the special setup wrt. > property change listeners on BaseDocument instances. But that seems like an > abstraction violation. -- This message was sent by Atlassian JIRA (v7.6.3#76005) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org For additional commands, e-mail: commits-h...@netbeans.apache.org For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists