From 5cdcf86cf9fd7bd25c3c140435b9c63bc8f830fd Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Wed, 1 May 2024 17:22:18 +0100 Subject: [PATCH] Properly pass connection exceptions to the logger --- .../proxy/connection/MinecraftConnection.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/MinecraftConnection.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/MinecraftConnection.java index 53d0a2364..b1c91ebdb 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/MinecraftConnection.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/MinecraftConnection.java @@ -195,8 +195,9 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter { boolean isQuietDecoderException = cause instanceof QuietDecoderException; boolean willLog = !isQuietDecoderException && !frontlineHandler; if (willLog) { - logger.error("{}: exception encountered in {}", association, activeSessionHandler, - cause); + logger.atError().withThrowable(cause) + .log("{}: exception encountered in {}", association, + activeSessionHandler); } else { knownDisconnect = true; } @@ -226,7 +227,6 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter { * Writes and immediately flushes a message to the connection. * * @param msg the message to write - * * @return A {@link ChannelFuture} that will complete when packet is successfully sent */ @Nullable @@ -370,12 +370,12 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter { this.state = state; // If the connection is LEGACY (<1.6), the decoder and encoder are not set. final MinecraftEncoder minecraftEncoder = this.channel.pipeline() - .get(MinecraftEncoder.class); + .get(MinecraftEncoder.class); if (minecraftEncoder != null) { minecraftEncoder.setState(state); } final MinecraftDecoder minecraftDecoder = this.channel.pipeline() - .get(MinecraftDecoder.class); + .get(MinecraftDecoder.class); if (minecraftDecoder != null) { minecraftDecoder.setState(state); } @@ -395,8 +395,8 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter { public void addPlayPacketQueueHandler() { if (this.channel.pipeline().get(Connections.PLAY_PACKET_QUEUE) == null) { this.channel.pipeline().addAfter(Connections.MINECRAFT_ENCODER, Connections.PLAY_PACKET_QUEUE, - new PlayPacketQueueHandler(this.protocolVersion, - channel.pipeline().get(MinecraftEncoder.class).getDirection())); + new PlayPacketQueueHandler(this.protocolVersion, + channel.pipeline().get(MinecraftEncoder.class).getDirection())); } }