From e690a7b38908df542a4950914eaa6e6a68fb5d97 Mon Sep 17 00:00:00 2001 From: md_5 Date: Sat, 31 Mar 2018 10:55:15 +1100 Subject: [PATCH] #1959: Leave ping exception logging to plugins --- .../net/md_5/bungee/netty/HandlerBoss.java | 45 ++++++++++--------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java b/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java index bf8ec29f..7e7cf7be 100644 --- a/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java +++ b/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java @@ -122,30 +122,35 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter { if ( ctx.channel().isActive() ) { - if ( cause instanceof ReadTimeoutException ) + boolean logExceptions = !( handler instanceof PingHandler ); + + if ( logExceptions ) { - ProxyServer.getInstance().getLogger().log( Level.WARNING, "{0} - read timed out", handler ); - } else if ( cause instanceof DecoderException && cause.getCause() instanceof BadPacketException ) - { - ProxyServer.getInstance().getLogger().log( Level.WARNING, "{0} - bad packet ID, are mods in use!? {1}", new Object[] + if ( cause instanceof ReadTimeoutException ) { - handler, cause.getCause().getMessage() - } ); - } else if ( cause instanceof DecoderException && cause.getCause() instanceof OverflowPacketException ) - { - ProxyServer.getInstance().getLogger().log( Level.WARNING, "{0} - overflow in packet detected! {1}", new Object[] + ProxyServer.getInstance().getLogger().log( Level.WARNING, "{0} - read timed out", handler ); + } else if ( cause instanceof DecoderException && cause.getCause() instanceof BadPacketException ) { - handler, cause.getCause().getMessage() - } ); - } else if ( cause instanceof IOException || ( cause instanceof IllegalStateException && handler instanceof InitialHandler ) ) - { - ProxyServer.getInstance().getLogger().log( Level.WARNING, "{0} - {1}: {2}", new Object[] + ProxyServer.getInstance().getLogger().log( Level.WARNING, "{0} - bad packet ID, are mods in use!? {1}", new Object[] + { + handler, cause.getCause().getMessage() + } ); + } else if ( cause instanceof DecoderException && cause.getCause() instanceof OverflowPacketException ) { - handler, cause.getClass().getSimpleName(), cause.getMessage() - } ); - } else - { - ProxyServer.getInstance().getLogger().log( Level.SEVERE, handler + " - encountered exception", cause ); + ProxyServer.getInstance().getLogger().log( Level.WARNING, "{0} - overflow in packet detected! {1}", new Object[] + { + handler, cause.getCause().getMessage() + } ); + } else if ( cause instanceof IOException || ( cause instanceof IllegalStateException && handler instanceof InitialHandler ) ) + { + ProxyServer.getInstance().getLogger().log( Level.WARNING, "{0} - {1}: {2}", new Object[] + { + handler, cause.getClass().getSimpleName(), cause.getMessage() + } ); + } else + { + ProxyServer.getInstance().getLogger().log( Level.SEVERE, handler + " - encountered exception", cause ); + } } if ( handler != null )