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 100127 - getSelectedObjects returns modifiable set
Summary: getSelectedObjects returns modifiable set
Status: NEW
Alias: None
Product: platform
Classification: Unclassified
Component: Graph (show other bugs)
Version: 3.x
Hardware: All All
: P3 blocker (vote)
Assignee: issues@platform
Depends on:
Reported: 2007-04-05 16:21 UTC by Joelle Lam
Modified: 2010-04-01 14:44 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:

image of drop down behind new watch dialog (179.71 KB, image/png)
2007-10-26 16:35 UTC, Joelle Lam

Note You need to log in before you can comment on or make changes to this bug.
Description Joelle Lam 2007-04-05 16:21:57 UTC
ObjectScene.getSelectedObjects should return UnModifiableSet.  While doing a for
each through the selected objects, it seems that the selected objects where
modified (since I deleting the selected objects one by one).

Exception thrown was this.  Any list like this should be a copy of the actual list.
        at java.util.HashMap$HashIterator.nextEntry(
        at java.util.HashMap$

The workaround would be to make my own copy.  David, do you think this is an issue?
Comment 1 David Kaspar 2007-04-05 19:59:32 UTC
I think the implementation is ok because performance reason. During
"setSelectedObjects" method call you would have to create a copy of the set -
current algorithm creates a copy of the set only for purpose of firing
SELECTION_CHANGED events to ObjectSceneListener.

The best would be to use CopyOnWriteHashSet (but it does not exist).

I would rather recomend you to create a copy of the set while you modifying the
ObjectScene structures.

I am closing the issue as WONTFIX. Feel free to reopen it if you disagree.
Comment 2 David Kaspar 2007-04-05 20:21:27 UTC
Reopening the issue. This behaviour has to be documented in documentation.html
and javadoc for all getter methods.
Comment 3 Joelle Lam 2007-10-26 16:35:03 UTC
Created attachment 51797 [details]
image of drop down behind new watch dialog
Comment 4 Joelle Lam 2007-10-26 16:38:45 UTC
oops added to wrong bug.  ignore that last attachment