From 07b775d892f26b9a90f8c82794ea4eb01fa7e8d7 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Sun, 17 Mar 2019 19:44:22 -0400 Subject: [PATCH] Notify on read-timeout instead of emitting exception --- .../proxy/connection/MinecraftConnection.java | 18 +++++++++++------- 1 file changed, 11 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 62a5e98c4..d654a685b 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/MinecraftConnection.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/MinecraftConnection.java @@ -31,6 +31,7 @@ import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.channel.EventLoop; import io.netty.handler.codec.haproxy.HAProxyMessage; +import io.netty.handler.timeout.ReadTimeoutException; import io.netty.util.ReferenceCountUtil; import java.net.InetSocketAddress; import java.net.SocketAddress; @@ -96,13 +97,12 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { - if (sessionHandler == null) { - // No session handler available, do nothing - ReferenceCountUtil.release(msg); - return; - } - try { + if (sessionHandler == null) { + // No session handler available, do nothing + return; + } + if (sessionHandler.beforeHandle()) { return; } @@ -137,7 +137,11 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter { } if (association != null) { - logger.error("{}: exception encountered", association, cause); + if (cause instanceof ReadTimeoutException) { + logger.error("{}: read timed out", association); + } else { + logger.error("{}: exception encountered", association, cause); + } } ctx.close();