Improve Timings stack protection more

Ensures in more places that exceptions will not corrupt the Timings stack.

Timings will now better report stack corruption and auto repair itself too.
This commit is contained in:
Aikar 2019-03-26 00:31:34 -04:00
parent f5e7717214
commit e055103d3d
No known key found for this signature in database
GPG key ID: 401ADFC9891FAAFE
3 changed files with 40 additions and 20 deletions

View file

@ -1,4 +1,4 @@
From 6c5e4653f78507a8553b8e9f915449a0ca3aa50f Mon Sep 17 00:00:00 2001
From e1e05e05e79b9ba25d403b5648b57c59b1c622cf Mon Sep 17 00:00:00 2001
From: Zach Brown <zach.brown@destroystokyo.com>
Date: Mon, 29 Feb 2016 20:24:35 -0600
Subject: [PATCH] Add exception reporting event
@ -462,7 +462,7 @@ index 000000000..5582999fe
+ }
+}
diff --git a/src/main/java/org/bukkit/command/SimpleCommandMap.java b/src/main/java/org/bukkit/command/SimpleCommandMap.java
index f7ec2e55f..f52d91d19 100644
index 6a786b8c5..682d27f94 100644
--- a/src/main/java/org/bukkit/command/SimpleCommandMap.java
+++ b/src/main/java/org/bukkit/command/SimpleCommandMap.java
@@ -9,6 +9,9 @@ import java.util.Iterator;
@ -477,13 +477,13 @@ index f7ec2e55f..f52d91d19 100644
import org.bukkit.Server;
@@ -148,11 +151,14 @@ public class SimpleCommandMap implements CommandMap {
target.execute(sender, sentCommandLabel, Arrays.copyOfRange(args, 1, args.length));
target.timings.stopTiming(); // Spigot
} // target.timings.stopTiming(); // Spigot // Paper
} catch (CommandException ex) {
+ server.getPluginManager().callEvent(new ServerExceptionEvent(new ServerCommandException(ex, target, sender, args))); // Paper
target.timings.stopTiming(); // Spigot
//target.timings.stopTiming(); // Spigot // Paper
throw ex;
} catch (Throwable ex) {
target.timings.stopTiming(); // Spigot
//target.timings.stopTiming(); // Spigot // Paper
- throw new CommandException("Unhandled exception executing '" + commandLine + "' in " + target, ex);
+ String msg = "Unhandled exception executing '" + commandLine + "' in " + target;
+ server.getPluginManager().callEvent(new ServerExceptionEvent(new ServerCommandException(ex, target, sender, args))); // Paper