Synchronize all access on packs
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 30 Apr 2015 04:39:17 +0000 (06:39 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 30 Apr 2015 04:39:17 +0000 (06:39 +0200)
src/main/java/net/pterodactylus/xdcc/data/Bot.java

index 3ca34f3..0f09671 100644 (file)
@@ -82,7 +82,9 @@ public class Bot implements Iterable<Pack> {
         * @return The packs this bot carries
         */
        public Collection<Pack> packs() {
-               return packs.values();
+               synchronized (packs) {
+                       return packs.values();
+               }
        }
 
        //
@@ -128,7 +130,7 @@ public class Bot implements Iterable<Pack> {
 
        @Override
        public Iterator<Pack> iterator() {
-               return packs.values().iterator();
+               return packs().iterator();
        }
 
        //