Ensure that iterating over targets never throws an exception.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Mon, 19 Sep 2011 19:19:54 +0000 (21:19 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Mon, 19 Sep 2011 19:19:54 +0000 (21:19 +0200)
src/main/java/net/pterodactylus/wotns/main/IdentityTargets.java

index 0222820..54dc660 100644 (file)
@@ -74,8 +74,10 @@ public class IdentityTargets implements Iterable<Entry<String, String>> {
         */
        @Override
        public Iterator<Entry<String, String>> iterator() {
-               scanForTargets();
-               return targets.entrySet().iterator();
+               synchronized (targets) {
+                       scanForTargets();
+                       return new HashMap<String, String>(targets).entrySet().iterator();
+               }
        }
 
 }