nea89o / Forge1.8.9Template

The Unlicense
135 stars 40 forks source link

Log configuration mutes all exceptions encountered in the Minecraft task queue #26

Open ILikePlayingGames opened 6 months ago

ILikePlayingGames commented 6 months ago

https://github.com/nea89o/Forge1.8.9Template/blob/09cd2809fbe4c3411c9065fd5b8a7fca52cceafd/log4j2.xml#L4

We should add narrower filtering to this. I encountered a scenario where some of my code running in the task queue failed silently and I discovered the exception was being muted by this

ILikePlayingGames commented 6 months ago

Sample of a stack trace we want to block

[02:51:43] [main/FATAL] (Minecraft) Error executing task
 java.util.concurrent.ExecutionException: java.lang.NullPointerException
    at java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[?:1.8.0_402]
    at java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[?:1.8.0_402]
    at net.minecraft.util.Util.runTask(Util.java:34) [Util.class:?]
    at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1004) [Minecraft.class:?]
    at net.minecraft.client.Minecraft.run(Minecraft.java:439) [Minecraft.class:?]
    at net.minecraft.client.main.Main.main(Main.java:100) [Main.class:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_402]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_402]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_402]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_402]
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
    at net.fabricmc.devlaunchinjector.Main.main(Main.java:86) [dev-launch-injector-0.2.1+build.8.jar:?]
Caused by: java.lang.NullPointerException
    at net.minecraft.scoreboard.Scoreboard.removeTeam(Scoreboard.java:262) ~[Scoreboard.class:?]
    at net.minecraft.client.network.NetHandlerPlayClient.handleTeams(NetHandlerPlayClient.java:1475) ~[NetHandlerPlayClient.class:?]
    at net.minecraft.network.play.server.S3EPacketTeams.processPacket(S3EPacketTeams.java:118) ~[S3EPacketTeams.class:?]
    at net.minecraft.network.play.server.S3EPacketTeams.processPacket(S3EPacketTeams.java:54) ~[S3EPacketTeams.class:?]
    at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:13) ~[PacketThreadUtil$1.class:?]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_402]
    at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266) ~[?:1.8.0_402]
    at java.util.concurrent.FutureTask.run(FutureTask.java) ~[?:1.8.0_402]
    at net.minecraft.util.Util.runTask(Util.java:33) ~[Util.class:?]
    ... 10 more
ILikePlayingGames commented 6 months ago

Not possible to filter stack trace on log4j 2.0-beta9, functionality not implemented :(

https://github.com/apache/logging-log4j2/tree/log4j-2.0-beta9/log4j-core/src/main/java/org/apache/logging/log4j/core/filter

ILikePlayingGames commented 6 months ago

Actually might be possible, idk if anyone wants to go through the effort to implement it though https://logging.apache.org/log4j/2.x/manual/plugins.html

nea89o commented 6 months ago

I think at that point a mod that just mixins into minecraft itself might be easier.

ILikePlayingGames commented 6 months ago

I think if there was to be a mod, it would be good to have it available to users too.

nea89o commented 6 months ago

I think if there was to be a mod, it would be good to have it available to users too.

Do you mean a mod that can be used by end users too? I feel like having a developer focused mod would be nice too. There could be some specialized mixins for client dev like warning for client commands that don't overwrite canPlayerUseCommand or similar things as well.

ILikePlayingGames commented 6 months ago

Yes, since Hypixel spams end user logs too. I thought about creating a dedicated dev tools mod but never had the time for it.

ILikePlayingGames commented 6 months ago

There’s this plugin for IntelliJ https://github.com/marcin-bukowiecki/breakpoint-manager-plugin idk if there’s an existing gradle one