From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Aikar Date: Sun, 10 May 2020 22:16:17 -0400 Subject: [PATCH] Wait for Async Tasks during shutdown Server.reload() had this logic to give time for tasks to shutdown, however shutdown did not... Adds a 5 second grace period for any async tasks to finish and warns if any are still running after that delay just as reload does. diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java index fe877316a1c347354ee8e0651bbc243fb5eddc81..4658883ffc150e38d29d5387784587e6299fab65 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -952,6 +952,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0) { + try { + Thread.sleep(100); + } catch (InterruptedException e) {} + pollCount++; + } + + List overdueWorkers = getScheduler().getActiveWorkers(); + for (BukkitWorker worker : overdueWorkers) { + Plugin plugin = worker.getOwner(); + String author = ""; + if (plugin.getDescription().getAuthors().size() > 0) { + author = plugin.getDescription().getAuthors().get(0); + } + getLogger().log(Level.SEVERE, String.format( + "Nag author: '%s' of '%s' about the following: %s", + author, + plugin.getDescription().getName(), + "This plugin is not properly shutting down its async tasks when it is being shut down. This task may throw errors during the final shutdown logs and might not complete before process dies." + )); + } + } + // Paper end + @Override public void reloadData() { ReloadCommand.reload(console);