tfmorris / simile-butterfly

Automatically exported from code.google.com/p/simile-butterfly
Apache License 2.0
1 stars 1 forks source link

ConcurrentModificationException in ButterflyScriptWatcher #8

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
In the run() method a for loop is iterating through the scripts HashMap which 
is not protected from mutation during the iteration:

        for (URL url : this.scripts.keySet()) {

both the run() and watch() methods need to synchronize access to this field.

Exception in thread "Timer-2" java.util.ConcurrentModificationException
    at java.util.HashMap$HashIterator.nextEntry(HashMap.java:793)
    at java.util.HashMap$KeyIterator.next(HashMap.java:828)
    at edu.mit.simile.butterfly.ButterflyScriptWatcher.run(Butterfly.java:1099)
    at java.util.TimerThread.mainLoop(Timer.java:512)
    at java.util.TimerThread.run(Timer.java:462)

Original issue reported on code.google.com by tfmorris on 18 Sep 2012 at 6:31

GoogleCodeExporter commented 9 years ago
An additional problem with this is that the exception kills the entire Java 
timer thread so that no other timer tasks fire because 
ButterflyScriptWatcher.run() doesn't catch the exception.  This affects the 
entire server, not just Butterfly related timers.

Original comment by tfmorris on 10 Aug 2013 at 12:05