Created
January 15, 2013 20:08
-
-
Save ddv2005/4541575 to your computer and use it in GitHub Desktop.
handle ConcurrentModification Exception
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/main/java/zmq/PollerBase.java b/src/main/java/zmq/PollerBase.java | |
index b1ad801..a37ed09 100644 | |
--- a/src/main/java/zmq/PollerBase.java | |
+++ b/src/main/java/zmq/PollerBase.java | |
@@ -99,7 +99,7 @@ abstract public class PollerBase { | |
// Get the current time. | |
long current = Clock.now_ms (); | |
- ArrayList <Long> removes = new ArrayList <Long> (); | |
+ ArrayList <Long> executes = new ArrayList <Long> (); | |
// Execute the timers that are already due. | |
long ret = 0L; | |
for (Entry <Long, TimerInfo> o : timers.entrySet ()) { | |
@@ -112,14 +112,20 @@ abstract public class PollerBase { | |
ret = o.getKey() - current; | |
break; | |
} | |
- | |
- // Trigger the timer. | |
- o.getValue().sink.timer_event (o.getValue().id); | |
- // Remove it from the list of active timers. | |
- removes.add (o.getKey ()); | |
+ | |
+ // Add timer toexecution list | |
+ executes.add (o.getKey ()); | |
} | |
- for (long key : removes) | |
+ for (long key : executes) | |
+ { | |
+ TimerInfo ti = timers.get(key); | |
+ if(ti!=null) | |
+ { | |
+ // Trigger the timer. | |
+ ti.sink.timer_event (ti.id); | |
+ } | |
timers.remove (key); | |
+ } | |
// There are no more timers. | |
return ret; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for addressing the issue.
Please send a pull request regarding this issue.
But please make sure the indentation is 4 spaces (no tabs).