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

Summary: getSelectedObjects returns modifiable set
Product: platform Reporter: Joelle Lam <joellelam>
Component: GraphAssignee: issues@platform <issues>
Status: NEW ---    
Severity: blocker    
Priority: P3    
Version: 3.x   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:
Attachments: image of drop down behind new watch dialog

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