From 1586de3418b7e5ee94a77089f871169911b108c6 Mon Sep 17 00:00:00 2001 From: Bjarne Koll Date: Sat, 12 Feb 2022 03:42:12 +0100 Subject: [PATCH] Log exceptions thrown during chat processing (#7467) --- ...ptions-thrown-during-chat-processing.patch | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 patches/server/Log-exceptions-thrown-during-chat-processing.patch diff --git a/patches/server/Log-exceptions-thrown-during-chat-processing.patch b/patches/server/Log-exceptions-thrown-during-chat-processing.patch new file mode 100644 index 0000000000..527e8ed87b --- /dev/null +++ b/patches/server/Log-exceptions-thrown-during-chat-processing.patch @@ -0,0 +1,30 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Bjarne Koll +Date: Sat, 12 Feb 2022 03:20:36 +0100 +Subject: [PATCH] Log exceptions thrown during chat processing + +Previously the async chat executor service would take chat handling +using the #submit method, which wraps the logic in a future task. +The future takes full ownership of the task, including any potential +exception, meaning that the uncaught exception handler never gets +notified about potential exceptions thrown during async chat logic. + +As the chat task does neither need to be cancelled nor returns something +required later on, this commit moves from #submit to #execute, skipping +any future task creation. This properly propagates any exception upwards +to the worker thread in the executor service, allowing the server to +catch and properly log the exception to the console. + +diff --git a/src/main/java/net/minecraft/network/protocol/game/ServerboundChatPacket.java b/src/main/java/net/minecraft/network/protocol/game/ServerboundChatPacket.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/network/protocol/game/ServerboundChatPacket.java ++++ b/src/main/java/net/minecraft/network/protocol/game/ServerboundChatPacket.java +@@ -0,0 +0,0 @@ public class ServerboundChatPacket implements Packet { + public void handle(final ServerGamePacketListener listener) { + if ( !this.message.startsWith("/") ) + { +- ServerboundChatPacket.executors.submit( new Runnable() ++ ServerboundChatPacket.executors.execute( new Runnable() // Paper - Use #execute to propagate exceptions up instead of swallowing them + { + + @Override