matthiasblaesing commented on code in PR #9096:
URL: https://github.com/apache/netbeans/pull/9096#discussion_r2637325794


##########
platform/core.execution/src/org/netbeans/core/execution/ExecutionEngine.java:
##########
@@ -193,24 +194,21 @@ protected final PermissionCollection 
createPermissions(CodeSource cs, InputOutpu
     /** fires event that notifies about new process */
     protected final void fireExecutionStarted (ExecutionEvent ev) {
         runningTasks.add( ev.getProcess() );
-       @SuppressWarnings("unchecked") 
-        Iterator<ExecutionListener> iter = ((HashSet<ExecutionListener>) 
executionListeners.clone()).iterator();
+        Iterator<ExecutionListener> iter = (new 
HashSet<>(executionListeners)).iterator();

Review Comment:
   ```suggestion
           Iterator<ExecutionListener> iter;
           synchronized(executionListeners) {
               iter = (new HashSet<>(executionListeners)).iterator();
           }
   ```



##########
platform/core.execution/src/org/netbeans/core/execution/ExecutionEngine.java:
##########
@@ -193,24 +194,21 @@ protected final PermissionCollection 
createPermissions(CodeSource cs, InputOutpu
     /** fires event that notifies about new process */
     protected final void fireExecutionStarted (ExecutionEvent ev) {
         runningTasks.add( ev.getProcess() );
-       @SuppressWarnings("unchecked") 
-        Iterator<ExecutionListener> iter = ((HashSet<ExecutionListener>) 
executionListeners.clone()).iterator();
+        Iterator<ExecutionListener> iter = (new 
HashSet<>(executionListeners)).iterator();
         while (iter.hasNext()) {
             ExecutionListener l = iter.next();
             l.startedExecution(ev);
-        }
+        }   
     }
 
     /** fires event that notifies about the end of a process */
     protected final void fireExecutionFinished (ExecutionEvent ev) {
-        runningTasks.remove( ev.getProcess() );
-       @SuppressWarnings("unchecked") 
-        Iterator<ExecutionListener> iter = ((HashSet<ExecutionListener>) 
executionListeners.clone()).iterator();
+        runningTasks.remove(ev.getProcess());
+        Iterator<ExecutionListener> iter = (new 
HashSet<>(executionListeners)).iterator();

Review Comment:
   ```suggestion
           Iterator<ExecutionListener> iter;
           sychronized(executionListeners) {
               iter = (new HashSet<>(executionListeners)).iterator();
           }
   ```



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