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 139980 - EditorRegistry.componentList() returns editors that are already closed
Summary: EditorRegistry.componentList() returns editors that are already closed
Status: VERIFIED WORKSFORME
Alias: None
Product: editor
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Vitezslav Stejskal
URL:
Keywords:
Depends on:
Blocks: 140059
  Show dependency tree
 
Reported: 2008-07-15 05:32 UTC by Vladimir Kvashin
Modified: 2009-02-19 20:45 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 Vladimir Kvashin 2008-07-15 05:32:57 UTC
Now EditorRegistry.componentList() returns editors that are already closed.
In particular, it contains editors that corresponds to file objects in projects that are already closed.
This leads to memory leaks and incorrect behavior in clients (such as C/C++ language model), because they consider that
these files are still open.
Comment 1 mslama 2008-07-15 10:04:37 UTC
Is there any way/test/module how to reproduce? Or is it just enough to write simple test which opens editor, closes it
and calls EditorRegistry.componentList()?
Comment 2 Vladimir Kvashin 2008-07-15 11:49:51 UTC
I don't have automated tests for this.
Yes, I believe opening editor, closing it and calling EditorRegistry.componentList() is quite enough to reproduce the
situation.
Comment 3 Vladimir Kvashin 2008-07-15 14:44:54 UTC
It seems that most memory leaks described in #140059 are caused by this issue
Comment 4 Quality Engineering 2008-07-25 15:45:56 UTC
Integrated into 'main-golden', available in NB_Trunk_Production #344 build
Changeset: http://hg.netbeans.org/main/rev/b79482bc9d6e
User: Vladimir Kvashin <vkvashin@netbeans.org>
Log: A workaround for #139980 (EditorRegistry.componentList() returns editors that are already closed)
Comment 5 mslama 2008-07-28 20:31:31 UTC
First it is in editor.lib2 not openide.text. Second javadoc does not say anything about opened/closed components.
Passing to editor for explanation.
Comment 6 Vladimir Kvashin 2008-07-29 11:36:51 UTC
The dependent issue is downgraded to P3, after I pushed a workaround:
for each editor in a list returned by registry, isOpen is checked:

private boolean isOpen(JEditorPane editor, FileObject fo) {
    DataObject dao = DataObject.find(fo);
    if (dao != null) {
        EditorCookie editorCookie = dao.getCookie(EditorCookie.class);
        if (editorCookie != null) {
            JEditorPane[] panes = editorCookie.getOpenedPanes();
            return panes != null && panes.length > 0;
        }
    }
}

However I still believe this is a bug in EditorRegistry.
Comment 7 Miloslav Metelka 2008-12-01 16:05:26 UTC
Strange, your editor possibly does not get through the conditions for closing of inactive TC - in EditorModule, search
for EditorApiPackageAccessor.get().notifyClose(tc) or there's some other problem.
I have added logging of ER.notifyClose(). It appears to work fine for both java and c files.
You may turn it on by -J-Dorg.netbeans.api.editor.EditorRegistry.level=FINEST to see if the closed editors are being
notified.
Closing as worksforme please reopen if the problem persists.

http://hg.netbeans.org/main/rev/9d967bbb38e9
Comment 8 Quality Engineering 2008-12-02 05:57:32 UTC
Integrated into 'main-golden', will be available in build *200812020201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/9d967bbb38e9
User: Miloslav Metelka <mmetelka@netbeans.org>
Log: #139980 - EditorRegistry.componentList() returns editors that are already closed - additional logging.
Comment 9 Vladimir Kvashin 2008-12-24 20:19:04 UTC
Can not reproduce any more (though when filing, it was reproduced 100%)