From 8ee9bdd6ffb1bdc608d41d3f8aee25ed522893f7 Mon Sep 17 00:00:00 2001 From: Jason <11360596+jpenilla@users.noreply.github.com> Date: Thu, 30 Sep 2021 13:05:51 -0500 Subject: [PATCH] Fix stacktrace deobf where thrownProxy got initialized before rewriting (#6684) --- ...ktraces-in-log-messages-crash-report.patch | 19 ++++++++++----- ...s-to-contain-the-source-jars-in-stac.patch | 23 ++++++------------- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/patches/server/0429-Deobfuscate-stacktraces-in-log-messages-crash-report.patch b/patches/server/0429-Deobfuscate-stacktraces-in-log-messages-crash-report.patch index 1d4818606f..6a5f871800 100644 --- a/patches/server/0429-Deobfuscate-stacktraces-in-log-messages-crash-report.patch +++ b/patches/server/0429-Deobfuscate-stacktraces-in-log-messages-crash-report.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Deobfuscate stacktraces in log messages, crash reports, and diff --git a/build.gradle.kts b/build.gradle.kts -index eea412347cef390555166a988058ae877afdfa4a..b35e54380cb23758a813fa24d13b888f36906c23 100644 +index fd037da8b655b329ef016356519a69ca2621fd4f..03c9f894a2eaa065c456843eef4d3ab1a25565c3 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,8 +1,12 @@ @@ -120,10 +120,10 @@ index 0bb4aaa546939b67a5d22865190f30478a9337c1..d3e619655382e50e9ac9323ed942502d diff --git a/src/main/java/io/papermc/paper/logging/StacktraceDeobfuscatingRewritePolicy.java b/src/main/java/io/papermc/paper/logging/StacktraceDeobfuscatingRewritePolicy.java new file mode 100644 -index 0000000000000000000000000000000000000000..d019802a36dbaca4bf299a55d28381e43d6b976f +index 0000000000000000000000000000000000000000..c701ef3c287f62aa0ebfbdbd6da6ed82a1c7793c --- /dev/null +++ b/src/main/java/io/papermc/paper/logging/StacktraceDeobfuscatingRewritePolicy.java -@@ -0,0 +1,31 @@ +@@ -0,0 +1,38 @@ +package io.papermc.paper.logging; + +import io.papermc.paper.util.StacktraceDeobfuscator; @@ -132,7 +132,8 @@ index 0000000000000000000000000000000000000000..d019802a36dbaca4bf299a55d28381e4 +import org.apache.logging.log4j.core.appender.rewrite.RewritePolicy; +import org.apache.logging.log4j.core.config.plugins.Plugin; +import org.apache.logging.log4j.core.config.plugins.PluginFactory; -+import org.jetbrains.annotations.NotNull; ++import org.apache.logging.log4j.core.impl.Log4jLogEvent; ++import org.checkerframework.checker.nullness.qual.NonNull; + +@Plugin( + name = "StacktraceDeobfuscatingRewritePolicy", @@ -141,17 +142,23 @@ index 0000000000000000000000000000000000000000..d019802a36dbaca4bf299a55d28381e4 + printObject = true +) +public final class StacktraceDeobfuscatingRewritePolicy implements RewritePolicy { ++ private StacktraceDeobfuscatingRewritePolicy() { ++ } ++ + @Override -+ public @NotNull LogEvent rewrite(final @NotNull LogEvent rewrite) { ++ public @NonNull LogEvent rewrite(final @NonNull LogEvent rewrite) { + final Throwable thrown = rewrite.getThrown(); + if (thrown != null) { + StacktraceDeobfuscator.INSTANCE.deobfuscateThrowable(thrown); ++ return new Log4jLogEvent.Builder(rewrite) ++ .setThrownProxy(null) ++ .build(); + } + return rewrite; + } + + @PluginFactory -+ public static @NotNull StacktraceDeobfuscatingRewritePolicy createPolicy() { ++ public static @NonNull StacktraceDeobfuscatingRewritePolicy createPolicy() { + return new StacktraceDeobfuscatingRewritePolicy(); + } +} diff --git a/patches/server/0726-Rewrite-LogEvents-to-contain-the-source-jars-in-stac.patch b/patches/server/0726-Rewrite-LogEvents-to-contain-the-source-jars-in-stac.patch index d77ec4b230..10cd90749d 100644 --- a/patches/server/0726-Rewrite-LogEvents-to-contain-the-source-jars-in-stac.patch +++ b/patches/server/0726-Rewrite-LogEvents-to-contain-the-source-jars-in-stac.patch @@ -230,26 +230,17 @@ index 0000000000000000000000000000000000000000..34734bb969a1a74c7a4f9c17d40ebf00 + } +} diff --git a/src/main/resources/log4j2.xml b/src/main/resources/log4j2.xml -index 2e421eaac80cf251b32e0bb504dd54a73edf4986..5704146ae84747cafd4b5f504ba071f6be99f425 100644 +index 2e421eaac80cf251b32e0bb504dd54a73edf4986..74ccc67e3c12dc5182602fb691ef3ddeb5b53280 100644 --- a/src/main/resources/log4j2.xml +++ b/src/main/resources/log4j2.xml -@@ -30,7 +30,7 @@ - - - -- -+ +@@ -34,6 +34,10 @@ -@@ -38,6 +38,10 @@ - - - ++ ++ + + -+ -+ - - - + + +