neilcsmith-net commented on code in PR #6872:
URL: https://github.com/apache/netbeans/pull/6872#discussion_r1443681373
##########
enterprise/javaee.wildfly/src/org/netbeans/modules/javaee/wildfly/ide/ui/AddServerLocationPanel.java:
##########
@@ -44,25 +42,15 @@ public class AddServerLocationPanel implements
WizardDescriptor.FinishablePanel,
private AddServerLocationVisualPanel component;
private WizardDescriptor wizard;
- private final transient Set listeners = ConcurrentHashMap.newKeySet(2);
+ private final transient Set<ChangeListener> listeners =
ConcurrentHashMap.newKeySet(2);
public AddServerLocationPanel(WildflyInstantiatingIterator
instantiatingIterator) {
this.instantiatingIterator = instantiatingIterator;
}
@Override
public void stateChanged(ChangeEvent ev) {
- fireChangeEvent(ev);
- }
-
- private void fireChangeEvent(ChangeEvent ev) {
- Iterator it;
- synchronized (listeners) {
- it = new HashSet(listeners).iterator();
- }
- while (it.hasNext()) {
- ((ChangeListener) it.next()).stateChanged(ev);
- }
+ listeners.iterator().forEachRemaining(l -> l.stateChanged(ev));
Review Comment:
In general for listeners, surely copying on add/remove is better than
copying on fire anyway - eg. `CopyOnWriteArraySet`? Iteration not being
randomly ordered is also a good thing here. And why are there concurrency
concerns with Swing listeners here in the first place?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists