? ~mcp.diff Index: MergedClassPathImplementation.java =================================================================== RCS file: /cvs/java/javacore/src/org/netbeans/modules/javacore/classpath/MergedClassPathImplementation.java,v retrieving revision 1.24.14.1.2.2 diff -u -r1.24.14.1.2.2 MergedClassPathImplementation.java --- MergedClassPathImplementation.java 29 Jun 2006 00:07:30 -0000 1.24.14.1.2.2 +++ MergedClassPathImplementation.java 13 Sep 2006 12:44:21 -0000 @@ -57,6 +57,7 @@ public static final String PROP_UNRESOLVED_ROOTS = "unresolvedRoots"; //NOI18N + private long eventCounter; private Set roots; private PropertyChangeSupport support; private GlobalPathRegistry reg; @@ -67,12 +68,14 @@ private GlobalPathRegistryListener gprListener; private PropertyChangeListener pcListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { - assert event != null : "event == null"; //NOI18N + assert event != null : "event == null"; //NOI18N + long id; synchronized (MergedClassPathImplementation.this) { roots = null; + id = (++eventCounter); } if (ClassPath.PROP_ENTRIES.equals(event.getPropertyName())) { - MergedClassPathImplementation.this.updateEntries((ClassPath)event.getSource()); + MergedClassPathImplementation.this.updateEntries((ClassPath)event.getSource(),id); } } }; @@ -268,39 +271,39 @@ ClassPath cp = (ClassPath) it.next(); this.addClassPath (cp); } - } + } - private void updateEntries (ClassPath cp) { + private void updateEntries (final ClassPath cp, final long eid) { boolean fire = false; List oldResources; - synchronized (this) { - oldResources = (List) this.resourceMap.remove (cp); - assert oldResources != null : "Change in unknown classpath"; // NOI18N - } List newResources = addClassPathResources (cp); synchronized (this) { - Collection toRemove = new HashSet (oldResources); - toRemove.removeAll (newResources); - newResources.removeAll (oldResources); //To Add - for (Iterator it = toRemove.iterator(); it.hasNext();) { - PathResourceImplementation resource = (PathResourceImplementation) it.next(); - oldResources.remove(resource); - if (!this.cachedResources.remove(resource)) { - if (!this.unresolvedRoots.remove (resource)) { - missingRoots.remove(resource.getRoots()[0]); + if (eid == eventCounter) { + oldResources = (List) this.resourceMap.remove (cp); + assert oldResources != null : "Change in unknown classpath"; // NOI18N + Collection toRemove = new HashSet (oldResources); + toRemove.removeAll (newResources); + newResources.removeAll (oldResources); //To Add + for (Iterator it = toRemove.iterator(); it.hasNext();) { + PathResourceImplementation resource = (PathResourceImplementation) it.next(); + oldResources.remove(resource); + if (!this.cachedResources.remove(resource)) { + if (!this.unresolvedRoots.remove (resource)) { + missingRoots.remove(resource.getRoots()[0]); + } + } + else { + fire = true; } } - else { - fire = true; + for (Iterator it = newResources.iterator(); it.hasNext();) { + PathResourceImplementation resource = (PathResourceImplementation) it.next(); + oldResources.add (resource); } + this.resourceMap.put (cp,oldResources); + this.unresolvedRoots.addAll(newResources); } - for (Iterator it = newResources.iterator(); it.hasNext();) { - PathResourceImplementation resource = (PathResourceImplementation) it.next(); - oldResources.add (resource); - } - this.resourceMap.put (cp,oldResources); - this.unresolvedRoots.addAll(newResources); } if (fire) { this.firePropertyChange(PROP_RESOURCES); @@ -365,7 +368,11 @@ //System.err.println("SourceForBinaryQuery.Result changed"); ClassPath classPath = (ClassPath) cp.get(); if (classPath != null) { - updateEntries(classPath); + long id; + synchronized (MergedClassPathImplementation.this) { + id = (++eventCounter); + } + updateEntries(classPath,id); } } } @@ -459,7 +466,7 @@ } } return null; - } + } public boolean containsKey (Object key) { if (key == null) {