Close #383 - swallow exceptions once and for all

This commit is contained in:
md_5 2013-05-24 14:16:43 +10:00
parent 1bf126d4f8
commit 32fdc83841
3 changed files with 28 additions and 2 deletions

View File

@ -5,7 +5,6 @@ import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundMessageHandlerAdapter;
import io.netty.handler.timeout.ReadTimeoutException;
import java.io.IOException;
import java.nio.channels.ClosedChannelException;
import java.util.logging.Level;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.connection.CancelSendSignal;
@ -85,7 +84,7 @@ public class HandlerBoss extends ChannelInboundMessageHandlerAdapter<byte[]>
} else if ( cause instanceof IOException )
{
ProxyServer.getInstance().getLogger().log( Level.WARNING, handler + " - IOException: " + cause.getMessage() );
} else if ( !( cause instanceof ClosedChannelException ) )
} else
{
ProxyServer.getInstance().getLogger().log( Level.SEVERE, handler + " - encountered exception", cause );
}

View File

@ -0,0 +1,25 @@
package net.md_5.bungee.netty;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOperationHandlerAdapter;
import io.netty.channel.ChannelPromise;
import java.nio.channels.ClosedChannelException;
public class OutboundHandler extends ChannelOperationHandlerAdapter
{
@Override
public void flush(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception
{
ctx.flush( promise );
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception
{
if ( !( cause instanceof ClosedChannelException ) )
{
ctx.fireExceptionCaught( cause );
}
}
}

View File

@ -58,6 +58,8 @@ public class PipelineUtils
{
// IP_TOS is not supported (Windows XP / Windows Server 2003)
}
ch.pipeline().addLast( "outbound", new OutboundHandler() );
ch.pipeline().addLast( "timer", new ReadTimeoutHandler( BungeeCord.getInstance().config.getTimeout(), TimeUnit.MILLISECONDS ) );
ch.pipeline().addLast( "decoder", new PacketDecoder( PacketDefinitions.VANILLA_PROTOCOL ) );
ch.pipeline().addLast( "packet-encoder", packetEncoder );