From ecdd6bf87e8e2bddb897e97a6089deefef04a91b Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 6 Jan 2013 17:33:42 +0100 Subject: [PATCH] Fix removal of chains. --- .../java/net/pterodactylus/reactor/loader/ChainWatcher.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/pterodactylus/reactor/loader/ChainWatcher.java b/src/main/java/net/pterodactylus/reactor/loader/ChainWatcher.java index 4a18a3e..3d30f26 100644 --- a/src/main/java/net/pterodactylus/reactor/loader/ChainWatcher.java +++ b/src/main/java/net/pterodactylus/reactor/loader/ChainWatcher.java @@ -21,8 +21,10 @@ import java.io.File; import java.io.FilenameFilter; import java.io.IOException; import java.util.HashMap; +import java.util.HashSet; import java.util.Map; import java.util.Map.Entry; +import java.util.Set; import java.util.concurrent.TimeUnit; import net.pterodactylus.reactor.Reaction; @@ -156,6 +158,7 @@ public class ChainWatcher extends AbstractExecutionThreadService { logger.debug(String.format("Found %d enabled Chain(s).", enabledChains.size())); /* check for removed chains. */ + Set chainsToRemove = new HashSet(); for (Entry loadedChain : loadedChains.entrySet()) { /* skip chains that still exist. */ @@ -165,7 +168,12 @@ public class ChainWatcher extends AbstractExecutionThreadService { logger.info(String.format("Removing Chain: %s", loadedChain.getKey())); engine.removeReaction(loadedChain.getKey()); - loadedChains.remove(loadedChain.getKey()); + chainsToRemove.add(loadedChain.getKey()); + } + + /* remove removed chains from loaded chains. */ + for (String reactionName : chainsToRemove) { + loadedChains.remove(reactionName); } /* check for new chains. */ -- 2.7.4