mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 23:38:25 +01:00
Fix stacktrace deobf where thrownProxy got initialized before rewriting (#6684)
This commit is contained in:
parent
e3ec51968c
commit
019c768488
2 changed files with 15 additions and 17 deletions
|
@ -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();
|
||||
+ }
|
||||
+}
|
||||
|
|
|
@ -234,22 +234,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
--- a/src/main/resources/log4j2.xml
|
||||
+++ b/src/main/resources/log4j2.xml
|
||||
@@ -0,0 +0,0 @@
|
||||
<DefaultRolloverStrategy max="1000"/>
|
||||
</RollingRandomAccessFile>
|
||||
<Async name="Async">
|
||||
- <AppenderRef ref="rewrite"/>
|
||||
+ <AppenderRef ref="rewrite2"/>
|
||||
</Async>
|
||||
<Rewrite name="rewrite">
|
||||
<StacktraceDeobfuscatingRewritePolicy />
|
||||
@@ -0,0 +0,0 @@
|
||||
<AppenderRef ref="TerminalConsole" level="info"/>
|
||||
<AppenderRef ref="ServerGuiConsole" level="info"/>
|
||||
</Rewrite>
|
||||
+ <AppenderRef ref="rewrite2"/>
|
||||
+ </Rewrite>
|
||||
+ <Rewrite name="rewrite2">
|
||||
+ <ExtraClassInfoRewritePolicy />
|
||||
+ <AppenderRef ref="rewrite"/>
|
||||
+ </Rewrite>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Root level="info">
|
||||
<AppenderRef ref="File"/>
|
||||
<AppenderRef ref="TerminalConsole" level="info"/>
|
||||
<AppenderRef ref="ServerGuiConsole" level="info"/>
|
||||
|
|
Loading…
Reference in a new issue