|
| 1 | +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Bjarne Koll <lynxplay101@gmail.com> |
| 3 | +Date: Sat, 12 Feb 2022 03:20:36 +0100 |
| 4 | +Subject: [PATCH] Log exceptions thrown during chat processing |
| 5 | + |
| 6 | +Previously the async chat executor service would take chat handling |
| 7 | +using the #submit method, which wraps the logic in a future task. |
| 8 | +The future takes full ownership of the task, including any potential |
| 9 | +exception, meaning that the uncaught exception handler never gets |
| 10 | +notified about potential exceptions thrown during async chat logic. |
| 11 | + |
| 12 | +As the chat task does neither need to be cancelled nor returns something |
| 13 | +required later on, this commit moves from #submit to #execute, skipping |
| 14 | +any future task creation. This properly propagates any exception upwards |
| 15 | +to the worker thread in the executor service, allowing the server to |
| 16 | +catch and properly log the exception to the console. |
| 17 | + |
| 18 | +diff --git a/src/main/java/net/minecraft/network/protocol/game/ServerboundChatPacket.java b/src/main/java/net/minecraft/network/protocol/game/ServerboundChatPacket.java |
| 19 | +index 8a0ced3f9b9099913ade4b71181aff6cafbc4ee6..21588ce5a408fed3454c317b56c05439ad3af27d 100644 |
| 20 | +--- a/src/main/java/net/minecraft/network/protocol/game/ServerboundChatPacket.java |
| 21 | ++++ b/src/main/java/net/minecraft/network/protocol/game/ServerboundChatPacket.java |
| 22 | +@@ -31,7 +31,7 @@ public class ServerboundChatPacket implements Packet<ServerGamePacketListener> { |
| 23 | + public void handle(final ServerGamePacketListener listener) { |
| 24 | + if ( !this.message.startsWith("/") ) |
| 25 | + { |
| 26 | +- ServerboundChatPacket.executors.submit( new Runnable() |
| 27 | ++ ServerboundChatPacket.executors.execute( new Runnable() // Paper - Use #execute to propagate exceptions up instead of swallowing them |
| 28 | + { |
| 29 | + |
| 30 | + @Override |
0 commit comments