From b7725a7764215b33382c502634a48bb647dc0cd9 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Tue, 28 Aug 2018 21:27:03 -0400 Subject: [PATCH] More sane shutdown code. --- .../velocitypowered/proxy/scheduler/VelocityScheduler.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/scheduler/VelocityScheduler.java b/proxy/src/main/java/com/velocitypowered/proxy/scheduler/VelocityScheduler.java index 3e87ab911..6e10807e3 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/scheduler/VelocityScheduler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/scheduler/VelocityScheduler.java @@ -12,6 +12,7 @@ import com.velocitypowered.api.scheduler.TaskStatus; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import java.util.Collection; import java.util.HashSet; import java.util.IdentityHashMap; import java.util.concurrent.*; @@ -41,7 +42,11 @@ public class VelocityScheduler implements Scheduler { } public boolean shutdown() throws InterruptedException { - for (ScheduledTask task : ImmutableList.copyOf(tasksByPlugin.values())) { + Collection terminating; + synchronized (tasksByPlugin) { + terminating = ImmutableList.copyOf(tasksByPlugin.values()); + } + for (ScheduledTask task : terminating) { task.cancel(); } timerExecutionService.shutdown();