summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWesley Wolfe <weswolf@aol.com>2012-12-23 05:13:33 -0600
committerWesley Wolfe <weswolf@aol.com>2012-12-23 05:13:33 -0600
commited6aab8200f0f28219ea01306a6f8b62f66bcbb2 (patch)
tree5978b0d028f68451fe5a9aec34e130311d7be46a /src
parent717fbbeffa8fe8eae00026ca06f95ebc5c3c00cf (diff)
downloadcraftbukkit-ed6aab8200f0f28219ea01306a6f8b62f66bcbb2.tar
craftbukkit-ed6aab8200f0f28219ea01306a6f8b62f66bcbb2.tar.gz
craftbukkit-ed6aab8200f0f28219ea01306a6f8b62f66bcbb2.tar.lz
craftbukkit-ed6aab8200f0f28219ea01306a6f8b62f66bcbb2.tar.xz
craftbukkit-ed6aab8200f0f28219ea01306a6f8b62f66bcbb2.zip
Remove runner leak on async tasks. Fixes BUKKIT-3288
In some situations, an async task could be cancelled with no tasks pending. This means the finally {} block from run() never gets executed properly on the last async task to have run, as it expected to be executed again. This fix takes the only spot that the task period is set to cancelled and will check to see if the task should be purged from the runners list.
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/bukkit/craftbukkit/scheduler/CraftAsyncTask.java3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftAsyncTask.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftAsyncTask.java
index 75a1a63a..f3da84a9 100644
--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftAsyncTask.java
+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftAsyncTask.java
@@ -100,6 +100,9 @@ class CraftAsyncTask extends CraftTask {
synchronized (workers) {
// Synchronizing here prevents race condition for a completing task
setPeriod(-2l);
+ if (workers.isEmpty()) {
+ runners.remove(getTaskId());
+ }
}
return true;
}