From 019c7684888e78bababc04d036a6cd3f238a3582 Mon Sep 17 00:00:00 2001 From: Jason Penilla <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 | 13 ++++++++++--- ...s-to-contain-the-source-jars-in-stac.patch | 19 +++++-------------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/patches/server/Deobfuscate-stacktraces-in-log-messages-crash-report.patch b/patches/server/Deobfuscate-stacktraces-in-log-messages-crash-report.patch index 240a290a36..f94e85f668 100644 --- a/patches/server/Deobfuscate-stacktraces-in-log-messages-crash-report.patch +++ b/patches/server/Deobfuscate-stacktraces-in-log-messages-crash-report.patch @@ -132,7 +132,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +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..00000000000000000000000000000000 + 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/Rewrite-LogEvents-to-contain-the-source-jars-in-stac.patch b/patches/server/Rewrite-LogEvents-to-contain-the-source-jars-in-stac.patch index dd46eae415..a6c29fb1fd 100644 --- a/patches/server/Rewrite-LogEvents-to-contain-the-source-jars-in-stac.patch +++ b/patches/server/Rewrite-LogEvents-to-contain-the-source-jars-in-stac.patch @@ -234,22 +234,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/resources/log4j2.xml +++ b/src/main/resources/log4j2.xml @@ -0,0 +0,0 @@ - - - -- -+ -@@ -0,0 +0,0 @@ - - - ++ ++ + + -+ -+ - - - + + +