#2535: Reduce verbosity of unhandled packet exception messages

This commit is contained in:
md_5 2018-12-21 10:15:36 +11:00
parent a47b803385
commit d689ba5904
5 changed files with 39 additions and 4 deletions

View File

@ -47,6 +47,7 @@ import net.md_5.bungee.protocol.packet.ScoreboardObjective;
import net.md_5.bungee.protocol.packet.ScoreboardScore; import net.md_5.bungee.protocol.packet.ScoreboardScore;
import net.md_5.bungee.protocol.packet.SetCompression; import net.md_5.bungee.protocol.packet.SetCompression;
import net.md_5.bungee.util.BufUtil; import net.md_5.bungee.util.BufUtil;
import net.md_5.bungee.util.QuietException;
@RequiredArgsConstructor @RequiredArgsConstructor
public class ServerConnector extends PacketHandler public class ServerConnector extends PacketHandler
@ -128,7 +129,7 @@ public class ServerConnector extends PacketHandler
{ {
if ( packet.packet == null ) if ( packet.packet == null )
{ {
throw new IllegalArgumentException( "Unexpected packet received during server login process!\n" + BufUtil.dump( packet.buf, 64 ) ); throw new QuietException( "Unexpected packet received during server login process!\n" + BufUtil.dump( packet.buf, 16 ) );
} }
} }
@ -292,7 +293,7 @@ public class ServerConnector extends PacketHandler
@Override @Override
public void handle(EncryptionRequest encryptionRequest) throws Exception public void handle(EncryptionRequest encryptionRequest) throws Exception
{ {
throw new RuntimeException( "Server is online mode!" ); throw new QuietException( "Server is online mode!" );
} }
@Override @Override

View File

@ -64,6 +64,7 @@ import net.md_5.bungee.protocol.packet.StatusRequest;
import net.md_5.bungee.protocol.packet.StatusResponse; import net.md_5.bungee.protocol.packet.StatusResponse;
import net.md_5.bungee.util.BoundedArrayList; import net.md_5.bungee.util.BoundedArrayList;
import net.md_5.bungee.util.BufUtil; import net.md_5.bungee.util.BufUtil;
import net.md_5.bungee.util.QuietException;
@RequiredArgsConstructor @RequiredArgsConstructor
public class InitialHandler extends PacketHandler implements PendingConnection public class InitialHandler extends PacketHandler implements PendingConnection
@ -134,7 +135,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
{ {
if ( packet.packet == null ) if ( packet.packet == null )
{ {
throw new IllegalArgumentException( "Unexpected packet received during login process!\n" + BufUtil.dump( packet.buf, 64 ) ); throw new QuietException( "Unexpected packet received during login process! " + BufUtil.dump( packet.buf, 16 ) );
} }
} }

View File

@ -19,6 +19,7 @@ import net.md_5.bungee.protocol.packet.Handshake;
import net.md_5.bungee.protocol.packet.StatusRequest; import net.md_5.bungee.protocol.packet.StatusRequest;
import net.md_5.bungee.protocol.packet.StatusResponse; import net.md_5.bungee.protocol.packet.StatusResponse;
import net.md_5.bungee.util.BufUtil; import net.md_5.bungee.util.BufUtil;
import net.md_5.bungee.util.QuietException;
@RequiredArgsConstructor @RequiredArgsConstructor
public class PingHandler extends PacketHandler public class PingHandler extends PacketHandler
@ -55,7 +56,7 @@ public class PingHandler extends PacketHandler
{ {
if ( packet.packet == null ) if ( packet.packet == null )
{ {
throw new IllegalArgumentException( "Unexpected packet received during ping process!\n" + BufUtil.dump( packet.buf, 64 ) ); throw new QuietException( "Unexpected packet received during ping process! " + BufUtil.dump( packet.buf, 16 ) );
} }
} }

View File

@ -16,6 +16,7 @@ import net.md_5.bungee.connection.PingHandler;
import net.md_5.bungee.protocol.BadPacketException; import net.md_5.bungee.protocol.BadPacketException;
import net.md_5.bungee.protocol.OverflowPacketException; import net.md_5.bungee.protocol.OverflowPacketException;
import net.md_5.bungee.protocol.PacketWrapper; import net.md_5.bungee.protocol.PacketWrapper;
import net.md_5.bungee.util.QuietException;
/** /**
* This class is a primitive wrapper for {@link PacketHandler} instances tied to * This class is a primitive wrapper for {@link PacketHandler} instances tied to
@ -147,6 +148,12 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
{ {
handler, cause.getClass().getSimpleName(), cause.getMessage() handler, cause.getClass().getSimpleName(), cause.getMessage()
} ); } );
} else if ( cause instanceof QuietException )
{
ProxyServer.getInstance().getLogger().log( Level.SEVERE, "{0} - encountered exception: {1}", new Object[]
{
handler, cause
} );
} else } else
{ {
ProxyServer.getInstance().getLogger().log( Level.SEVERE, handler + " - encountered exception", cause ); ProxyServer.getInstance().getLogger().log( Level.SEVERE, handler + " - encountered exception", cause );

View File

@ -0,0 +1,25 @@
package net.md_5.bungee.util;
/**
* Exception without a stack trace component.
*/
public class QuietException extends RuntimeException
{
public QuietException(String message)
{
super( message );
}
@Override
public Throwable initCause(Throwable cause)
{
return this;
}
@Override
public Throwable fillInStackTrace()
{
return this;
}
}