BradWalker commented on code in PR #9091:
URL: https://github.com/apache/netbeans/pull/9091#discussion_r2636771335


##########
platform/core.execution/src/org/netbeans/core/execution/ExecutionEngine.java:
##########
@@ -194,7 +195,7 @@ protected final PermissionCollection 
createPermissions(CodeSource cs, InputOutpu
     protected final void fireExecutionStarted (ExecutionEvent ev) {
         runningTasks.add( ev.getProcess() );
        @SuppressWarnings("unchecked") 
-        Iterator<ExecutionListener> iter = ((HashSet<ExecutionListener>) 
executionListeners.clone()).iterator();
+        Iterator<ExecutionListener> iter = executionListeners.iterator();

Review Comment:
   > This makes me nervous. Why is the removal of the `clone` safe? HashMaps 
are not synchronized and if I remember correctly iteration of a map that is 
modified by another thread is undefined behavior. The clone removes the need 
for synchronization (at least I would read it as such).
   
   Had to look into this more. You are correct. I updated this so that a 
synchronizedSet is used. This seems to be a better choice compared to making a 
copy of the Set. The code is cleaner and correct.
   
   Good eyes. Thanks for catching this. I learned something here..
   



-- 
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

Reply via email to