Scan for targets before iterating over targets.
[WoTNS.git] / src / main / java / net / pterodactylus / wotns / main / IdentityTargets.java
index 2eacd08..0222820 100644 (file)
@@ -56,6 +56,7 @@ public class IdentityTargets implements Iterable<Entry<String, String>> {
 
        private void scanForTargets() {
                synchronized (targets) {
+                       targets.clear();
                        for (Entry<String, String> property : identity.getProperties().entrySet()) {
                                if (property.getKey().startsWith("tns.")) {
                                        targets.put(property.getKey().substring(4), property.getValue());
@@ -73,6 +74,7 @@ public class IdentityTargets implements Iterable<Entry<String, String>> {
         */
        @Override
        public Iterator<Entry<String, String>> iterator() {
+               scanForTargets();
                return targets.entrySet().iterator();
        }