Fix for issue #162415 - java.util.ConcurrentModificationException at org.openide.util.WeakSet$WeakSetIterator.checkModcount diff -r cc7446f2caa0 projectui/src/org/netbeans/modules/project/ui/ProjectsRootNode.java --- a/projectui/src/org/netbeans/modules/project/ui/ProjectsRootNode.java Mon Apr 13 02:21:09 2009 +0400 +++ b/projectui/src/org/netbeans/modules/project/ui/ProjectsRootNode.java Mon Apr 13 10:19:05 2009 +0400 @@ -105,7 +105,7 @@ public class ProjectsRootNode extends AbstractNode { private static final Logger LOG = Logger.getLogger(ProjectsRootNode.class.getName()); - private static final Set all = new WeakSet(); + private static final Set all = Collections.synchronizedSet(new WeakSet()); static final int PHYSICAL_VIEW = 0; static final int LOGICAL_VIEW = 1; @@ -120,7 +120,9 @@ super( new ProjectChildren( type ) ); setIconBaseWithExtension( ICON_BASE ); this.type = type; - all.add(this); + synchronized(all){ + all.add(this); + } } public String getName() { @@ -202,13 +204,15 @@ } static void checkNoLazyNode(Object msg) { - for (ProjectsRootNode root : all) { - for (Node n : root.getChildren().getNodes()) { - if (n.getLookup().lookup(LazyProject.class) != null) { - LogRecord REC = new LogRecord(Level.WARNING, "LazyProjects remain visible:\n {0}"); // NOI18N - REC.setLoggerName(OpenProjectList.LOGGER.getName()); - REC.setParameters(new Object[] { msg }); - OpenProjectList.log(REC); + synchronized(all){ + for (ProjectsRootNode root : all) { + for (Node n : root.getChildren().getNodes()) { + if (n.getLookup().lookup(LazyProject.class) != null) { + LogRecord REC = new LogRecord(Level.WARNING, "LazyProjects remain visible:\n {0}"); // NOI18N + REC.setLoggerName(OpenProjectList.LOGGER.getName()); + REC.setParameters(new Object[] { msg }); + OpenProjectList.log(REC); + } } } }