1
0
Fork 0
mirror of https://github.com/PaperMC/Paper.git synced 2025-02-16 18:31:53 +01:00

Don't grab the threads stacktrace when dumping same thread

For some reason, this doesn't always seem to capture all states of shutdown,
either the logger is just being fun, or, potentially, the thread is already
marked as dead when we're getting called so the trace is not generated through
the method on Thread
This commit is contained in:
Shane Freeder 2021-02-24 18:45:21 +00:00
parent bbb0f52210
commit 1487ee284e

View file

@ -23,6 +23,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ Bukkit.getLogger().warning("\tat " + traceElement);
+ }
+ }
+
+ public static void dumpTraceForThread(String reason) {
+ new Throwable(reason).printStackTrace();
+ }
+}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
@ -48,7 +52,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (hasStopped) return;
hasStopped = true;
}
+ if (!hasLoggedStop && isDebugging()) TraceUtil.dumpTraceForThread(this.getThread(), "Server stopped"); // Paper
+ if (!hasLoggedStop && isDebugging()) TraceUtil.dumpTraceForThread("Server stopped"); // Paper
// Paper start - kill main thread, and kill it hard
shutdownThread = Thread.currentThread();
org.spigotmc.WatchdogThread.doStop(); // Paper
@ -57,7 +61,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.isRunning = false;
this.isRestarting = isRestarting;
+ this.hasLoggedStop = true; // Paper
+ if (isDebugging()) TraceUtil.dumpTraceForThread(this.getThread(), "Server stopped"); // Paper
+ if (isDebugging()) TraceUtil.dumpTraceForThread("Server stopped"); // Paper
if (flag) {
try {
this.serverThread.join();