Update of /var/cvs/src/org/mmbase/util
In directory james.mmbase.org:/tmp/cvs-serv15195

Modified Files:
        FileWatcher.java 
Log Message:
dammit


See also: http://cvs.mmbase.org/viewcvs/src/org/mmbase/util


Index: FileWatcher.java
===================================================================
RCS file: /var/cvs/src/org/mmbase/util/FileWatcher.java,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -b -r1.51 -r1.52
--- FileWatcher.java    30 Jul 2008 11:34:35 -0000      1.51
+++ FileWatcher.java    31 Jul 2008 14:31:01 -0000      1.52
@@ -63,7 +63,7 @@
  * @author Eduard Witteveen
  * @author Michiel Meeuwissen
  * @since  MMBase-1.4
- * @version $Id: FileWatcher.java,v 1.51 2008/07/30 11:34:35 michiel Exp $
+ * @version $Id: FileWatcher.java,v 1.52 2008/07/31 14:31:01 michiel Exp $
  */
 public abstract class FileWatcher {
     private static Logger log = Logging.getLoggerInstance(FileWatcher.class);
@@ -379,9 +379,8 @@
         public void run() {
             try {
                 long now = System.currentTimeMillis();
-                Iterator<FileWatcher> i =  watchers.iterator();
-                while(i.hasNext()) {
-                    FileWatcher f = i.next();
+                List<FileWatcher> removed = new ArrayList<FileWatcher>(); // 
copyonwritearraylist's iterator  does not support remove
+                for (FileWatcher f : watchers) {
                     long staleness = (now - f.lastCheck);
                     if (staleness >= f.delay) {
                         if (log.isTraceEnabled()) {
@@ -394,11 +393,14 @@
                             if (log.isDebugEnabled()) {
                                 log.debug("Removing filewatcher " + f + " " + 
f.mustStop());
                             }
-                            i.remove();
+                            removed.add(f);
                         }
                         f.lastCheck = now;
                     }
                 }
+                if (removed.size() > 0) {
+                    watchers.removeAll(removed);
+                }
             } catch (Throwable ex) {
                 // unexpected exception?? This run method should never 
interrupt, so we catch everything.
                 log.error("Exception: " + ex.getClass().getName() + ": " + 
ex.getMessage() + Logging.stackTrace(ex));
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to