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.
Summary: | TopComponent.getRegistry().getOpened() not safe to iterate | ||
---|---|---|---|
Product: | platform | Reporter: | Jaroslav Tulach <jtulach> |
Component: | Window System | Assignee: | Jaroslav Tulach <jtulach> |
Status: | RESOLVED FIXED | ||
Severity: | blocker | CC: | jglick, saubrecht |
Priority: | P2 | Keywords: | THREAD |
Version: | 6.x | ||
Hardware: | All | ||
OS: | All | ||
Issue Type: | DEFECT | Exception Reporter: | |
Attachments: | Implementation that is both iterable and live |
Description
Jaroslav Tulach
2009-09-11 10:30:19 UTC
P1 since it is blocking core-main propagation. Starting failing in a build in which I pushed project system changes; don't see offhand how that could be related. It may not be related to threading. The code: for (TopComponent tc : TopComponent.getRegistry().getOpened()) { tc.close(); } is likely to fail in case there are at least two top components. Easy to write unit test for it, I am sure. The reason why the test was passing before is that Jelly managed to close all editors before my code run. Is not the test broken by some other changes that prevent documents to be closed? well, i can make TopComponent.Registry.getOpened() safe to iterate but the javadoc says: @return live read-only set of {@link TopComponent}s so this fix is likely to break some other functionality which depends on the set being live. I think IDEValidation is failing due to some bundle issues which I will fix. The two usages of Registry.getOpened in WatchProjects are nonetheless still probably wrong. Integrated into 'main-golden', will be available in build *200909131354* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-golden/rev/de67067bd697 User: Jesse Glick <jglick@netbeans.org> Log: #172012: do not iterate over a set (TC.Registry.opened) whose elements might be being deleted. I still suggest this is fixed. It is not that strange code to write. Also the implementation shall be made consistent between the two implementations we have. The default one in openide.windows and the real one in core.windows. Created attachment 87758 [details]
Implementation that is both iterable and live
go ahead and integrate the patch, it looks fine to me (or it might be easier to introduce method Set<TopComponent> getOpenedSnapshot() to provide a copied set of topcomponents that were opened at the time of the calling of the method) core-main#6608ef539ffd Btw. the TC.Registry is (mistakenly) a Java interface, so adding methods to it is not something I'd like to advocate. Thus I have chosen to improve the implementation of existing method. Integrated into 'main-golden', will be available in build *200909181401* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-golden/rev/6608ef539ffd User: Jaroslav Tulach <jtulach@netbeans.org> Log: #172012: Live and safely iterable Set from getOpened() method |