Put logging exception handlers on all channel inbounds. Fix problem with failure to login. Closes #350

This commit is contained in:
Christian committed 2014-01-17 17:00:55 -05:00
1 parent 9c96ca4402
commit 53557dcd05
10 files changed
+78 -3

No files matched your search

@@ -144,6 +144,8 @@ public class FMLClientHandler implements IFMLSidedHandler
private Map<ServerStatusResponse,JsonObject> extraServerListData;
private Map<ServerData, ExtendedServerListData> serverDataTag;
private NetHandlerPlayClient currentPlayClient;
/**
* Called to start the whole game off
*
@@ -532,7 +534,7 @@ public class FMLClientHandler implements IFMLSidedHandler
@Override
public INetHandler getClientPlayHandler()
{
return this.client.func_147114_u();
return this.currentPlayClient;
}
@Override
public NetworkManager getClientToServerNetworkManager()
@@ -697,6 +699,7 @@ public class FMLClientHandler implements IFMLSidedHandler
public void setPlayClient(NetHandlerPlayClient netHandlerPlayClient)
{
playClientBlock.countDown();
this.currentPlayClient = netHandlerPlayClient;
}
@Override
@@ -1,5 +1,7 @@
package cpw.mods.fml.common.network;
import org.apache.logging.log4j.Level;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
@@ -26,4 +28,10 @@ public class NetworkEventFiringHandler extends SimpleChannelInboundHandler<FMLPr
eventChannel.fireRead(msg,ctx);
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception
{
FMLLog.log(Level.ERROR, cause, "NetworkEventFiringHandler exception");
super.exceptionCaught(ctx, cause);
}
}
@@ -4,10 +4,11 @@ import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import java.util.Set;
import net.minecraft.network.NetworkManager;
import org.apache.logging.log4j.Level;
import com.google.common.base.Charsets;
import com.google.common.collect.ImmutableSet;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
import cpw.mods.fml.relauncher.Side;
@@ -15,7 +16,7 @@ public class ChannelRegistrationHandler extends SimpleChannelInboundHandler<FMLP
@Override
protected void channelRead0(ChannelHandlerContext ctx, FMLProxyPacket msg) throws Exception
{
Side side = ctx.channel().attr(NetworkRegistry.CHANNEL_SOURCE).get();
Side side = msg.getTarget();
NetworkManager manager = msg.getOrigin();
if (msg.channel().equals("REGISTER") || msg.channel().equals("UNREGISTER"))
{
@@ -32,4 +33,10 @@ public class ChannelRegistrationHandler extends SimpleChannelInboundHandler<FMLP
}
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception
{
FMLLog.log(Level.ERROR, cause, "ChannelRegistrationHandler exception");
super.exceptionCaught(ctx, cause);
}
}
@@ -1,5 +1,6 @@
package cpw.mods.fml.common.network.handshake;
import org.apache.logging.log4j.Level;
import cpw.mods.fml.common.FMLLog;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
@@ -39,4 +40,11 @@ public class HandshakeMessageHandler<S extends Enum<S> & IHandshakeState<S>> ext
S newState = state.accept(ctx, null);
ctx.attr(fmlHandshakeState).set(newState);
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception
{
FMLLog.log(Level.ERROR, cause, "HandshakeMessageHandler exception");
super.exceptionCaught(ctx, cause);
}
}
@@ -15,6 +15,7 @@ import java.util.List;
import java.util.Locale;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
import org.apache.logging.log4j.Level;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.EnumConnectionState;
import net.minecraft.network.INetHandler;
@@ -242,6 +243,7 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler<Packet> imple
if ("FML|HS".equals(channelName) || "REGISTER".equals(channelName) || "UNREGISTER".equals(channelName))
{
FMLProxyPacket proxy = new FMLProxyPacket(msg);
proxy.setDispatcher(this);
handshakeChannel.writeInbound(proxy);
// forward any messages into the regular channel
for (Object push : handshakeChannel.inboundMessages())
@@ -278,6 +280,7 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler<Packet> imple
if ("FML|HS".equals(channelName) || "REGISTER".equals(channelName) || "UNREGISTER".equals(channelName))
{
FMLProxyPacket proxy = new FMLProxyPacket(msg);
proxy.setDispatcher(this);
handshakeChannel.writeInbound(proxy);
for (Object push : handshakeChannel.inboundMessages())
{
@@ -433,4 +436,12 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler<Packet> imple
{
completeClientSideConnection(ConnectionType.valueOf(type));
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception
{
FMLLog.log(Level.ERROR, cause, "NetworkDispatcher exception");
super.exceptionCaught(ctx, cause);
}
}
@@ -123,4 +123,11 @@ public class EntitySpawnHandler extends SimpleChannelInboundHandler<FMLMessage.E
throw Throwables.propagate(e);
}
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception
{
FMLLog.log(Level.ERROR, cause, "EntitySpawnHandler exception");
super.exceptionCaught(ctx, cause);
}
}
@@ -108,4 +108,9 @@ public class FMLProxyPacket extends Packet {
{
return this.dispatcher;
}
public Side getTarget()
{
return target;
}
}
@@ -1,5 +1,7 @@
package cpw.mods.fml.common.network.internal;
import org.apache.logging.log4j.Level;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.network.handshake.NetworkDispatcher;
import cpw.mods.fml.common.network.internal.FMLMessage.CompleteHandshake;
import io.netty.channel.ChannelHandlerContext;
@@ -14,4 +16,11 @@ public class HandshakeCompletionHandler extends SimpleChannelInboundHandler<FMLM
NetworkDispatcher dispatcher = ctx.channel().attr(NetworkDispatcher.FML_DISPATCHER).getAndRemove();
dispatcher.completeHandshake(msg.target);
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception
{
FMLLog.log(Level.ERROR, cause, "HandshakeCompletionHandler exception");
super.exceptionCaught(ctx, cause);
}
}
@@ -1,9 +1,11 @@
package cpw.mods.fml.common.network.internal;
import org.apache.logging.log4j.Level;
import net.minecraft.entity.player.EntityPlayer;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.network.internal.FMLMessage.OpenGui;
public class OpenGuiHandler extends SimpleChannelInboundHandler<FMLMessage.OpenGui> {
@@ -15,4 +17,11 @@ public class OpenGuiHandler extends SimpleChannelInboundHandler<FMLMessage.OpenG
player.field_71070_bA.field_75152_c = msg.windowId;
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception
{
FMLLog.log(Level.ERROR, cause, "OpenGuiHandler exception");
super.exceptionCaught(ctx, cause);
}
}
@@ -1,7 +1,9 @@
package cpw.mods.fml.common.network.simpleimpl;
import org.apache.logging.log4j.Level;
import net.minecraft.network.INetHandler;
import com.google.common.base.Throwables;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.relauncher.Side;
import io.netty.channel.ChannelHandlerContext;
@@ -33,4 +35,10 @@ public class SimpleChannelHandlerWrapper<REQ extends IMessage, REPLY extends IMe
}
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception
{
FMLLog.log(Level.ERROR, cause, "SimpleChannelHandlerWrapper exception");
super.exceptionCaught(ctx, cause);
}
}