skip printStackTrace when finding caller

This commit is contained in:
Jason Penilla 2023-11-05 17:27:00 -07:00
parent f9e368621d
commit bbc57469ab
No known key found for this signature in database
GPG key ID: 0E75A301420E48F8

View file

@ -6,10 +6,10 @@ Subject: [PATCH] Add System.out/err catcher
diff --git a/src/main/java/io/papermc/paper/logging/SysoutCatcher.java b/src/main/java/io/papermc/paper/logging/SysoutCatcher.java
new file mode 100644
index 0000000000000000000000000000000000000000..1995639aee39627d2e0cf8ca9c4b4fa38b64da50
index 0000000000000000000000000000000000000000..64b8bf47162811334a934136d6aaa6c71a0f47ee
--- /dev/null
+++ b/src/main/java/io/papermc/paper/logging/SysoutCatcher.java
@@ -0,0 +1,227 @@
@@ -0,0 +1,229 @@
+package io.papermc.paper.logging;
+
+import java.io.FilterOutputStream;
@ -66,7 +66,9 @@ index 0000000000000000000000000000000000000000..1995639aee39627d2e0cf8ca9c4b4fa3
+ final Class<?> clazz = STACK_WALKER.walk(stream -> {
+ return stream.filter(it -> {
+ final Class<?> declr = it.getDeclaringClass();
+ return !declr.equals(WrappedOutStream.class) && !declr.equals(PrintStream.class) && !declr.equals(FilterOutputStream.class);
+ return !declr.equals(WrappedOutStream.class) && !declr.equals(PrintStream.class)
+ && !declr.equals(FilterOutputStream.class) && !declr.getName().equals("java.lang.Throwable$WrappedPrintStream")
+ && !declr.equals(Throwable.class);
+ }).findFirst()
+ .map(StackWalker.StackFrame::getDeclaringClass)
+ .orElseThrow();