Added some more synchronization to toString() method to prevent ConcurrentModificationExceptions. BLD200304090100
authormentlicher@netbeans.org
Tue, 08 Apr 2003 16:23:42 +0000
changeset 334925f4d6a62479
parent 3348 78108028c232
child 3350 064f62f7fb7e
Added some more synchronization to toString() method to prevent ConcurrentModificationExceptions.
Also the whole method is commented out. This should be uncommented only for debug purposes.
I've found, that this method is called when someone calls RequestProcessor.Task.toString(). This may slow down the IDE.
vcscore/src/org/netbeans/modules/vcscore/objectintegrity/VcsObjectIntegritySupport.java
     1.1 --- a/vcscore/src/org/netbeans/modules/vcscore/objectintegrity/VcsObjectIntegritySupport.java	Tue Apr 08 15:17:12 2003 +0000
     1.2 +++ b/vcscore/src/org/netbeans/modules/vcscore/objectintegrity/VcsObjectIntegritySupport.java	Tue Apr 08 16:23:42 2003 +0000
     1.3 @@ -500,7 +500,7 @@
     1.4      
     1.5      /**
     1.6       * Provides the String representation. Mainly for debug purposes.
     1.7 -     */
     1.8 +     *
     1.9      public String toString() {
    1.10          StringBuffer localSecondaryFiles = new StringBuffer();
    1.11          int numLocSec;
    1.12 @@ -515,28 +515,35 @@
    1.13                  if (it.hasNext()) localSecondaryFiles.append(",\n");
    1.14              }
    1.15              numLocSec = filesMap.size();
    1.16 -            for (Iterator it = primaryLocalFiles.iterator(); it.hasNext(); ) {
    1.17 +            synchronized (primaryLocalFiles) {
    1.18 +                for (Iterator it = primaryLocalFiles.iterator(); it.hasNext(); ) {
    1.19 +                    String name = (String) it.next();
    1.20 +                    primaryLocal.append("\t");
    1.21 +                    primaryLocal.append(name);
    1.22 +                    if (it.hasNext()) primaryLocal.append(",\n");
    1.23 +                }
    1.24 +                numPrimLoc = primaryLocalFiles.size();
    1.25 +            }
    1.26 +        }
    1.27 +        int numIgnored;
    1.28 +        synchronized (ignoredSecondaryLocalFiles) {
    1.29 +            for (Iterator it = ignoredSecondaryLocalFiles.iterator(); it.hasNext(); ) {
    1.30                  String name = (String) it.next();
    1.31 -                primaryLocal.append("\t");
    1.32 -                primaryLocal.append(name);
    1.33 -                if (it.hasNext()) primaryLocal.append(",\n");
    1.34 +                ignored.append("\t");
    1.35 +                ignored.append(name);
    1.36 +                if (it.hasNext()) ignored.append(",\n");
    1.37              }
    1.38 -            numPrimLoc = primaryLocalFiles.size();
    1.39 -        }
    1.40 -        for (Iterator it = ignoredSecondaryLocalFiles.iterator(); it.hasNext(); ) {
    1.41 -            String name = (String) it.next();
    1.42 -            ignored.append("\t");
    1.43 -            ignored.append(name);
    1.44 -            if (it.hasNext()) ignored.append(",\n");
    1.45 +            numIgnored = ignoredSecondaryLocalFiles.size();
    1.46          }
    1.47          return "VcsObjectIntegritySupport "+Integer.toHexString(hashCode())+"\n"+
    1.48              "  Local Secondary Files: "+numLocSec+"\n"+
    1.49              ((localSecondaryFiles.length() > 0) ? localSecondaryFiles.toString()+"\n" : "")+
    1.50              "  Local Primary Files: "+numPrimLoc+"\n"+
    1.51              ((primaryLocal.length() > 0) ? primaryLocal.toString()+"\n" : "")+
    1.52 -            "  Ignored Local Secondary Files: "+ignoredSecondaryLocalFiles.size()+"\n"+
    1.53 +            "  Ignored Local Secondary Files: "+numIgnored+"\n"+
    1.54              ((ignored.length() > 0) ? ignored.toString()+"\n" : "");
    1.55      }
    1.56 +     */
    1.57      
    1.58      
    1.59      /**