From 4b0afe6ff9f34b0233ab434feb6d155c72a70718 Mon Sep 17 00:00:00 2001 From: Prototik Date: Mon, 1 Jun 2015 18:30:50 +0700 Subject: [PATCH] Attempt to avoid npe during handshake --- .../HandshakeCompletionHandler.java.patch | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/patches/cpw/mods/fml/common/network/internal/HandshakeCompletionHandler.java.patch b/patches/cpw/mods/fml/common/network/internal/HandshakeCompletionHandler.java.patch index 64edf7c..70f42c4 100644 --- a/patches/cpw/mods/fml/common/network/internal/HandshakeCompletionHandler.java.patch +++ b/patches/cpw/mods/fml/common/network/internal/HandshakeCompletionHandler.java.patch @@ -1,18 +1,19 @@ --- ../src-base/minecraft/cpw/mods/fml/common/network/internal/HandshakeCompletionHandler.java +++ ../src-work/minecraft/cpw/mods/fml/common/network/internal/HandshakeCompletionHandler.java -@@ -13,9 +13,15 @@ +@@ -13,8 +13,14 @@ @Override protected void channelRead0(ChannelHandlerContext ctx, CompleteHandshake msg) throws Exception { +- NetworkDispatcher dispatcher = ctx.channel().attr(NetworkDispatcher.FML_DISPATCHER).getAndRemove(); +- dispatcher.completeHandshake(msg.target); + // Cauldron start - attempt to fix race condition with attr being null -+ Object attr = ctx.channel().attr(NetworkDispatcher.FML_DISPATCHER); ++ io.netty.util.Attribute attr = ctx.channel().attr(NetworkDispatcher.FML_DISPATCHER); + if (attr != null) + { - NetworkDispatcher dispatcher = ctx.channel().attr(NetworkDispatcher.FML_DISPATCHER).getAndRemove(); - dispatcher.completeHandshake(msg.target); - } ++ NetworkDispatcher dispatcher = attr.getAndRemove(); ++ if (dispatcher != null) dispatcher.completeHandshake(msg.target); ++ } + // Cauldron end -+ } + } @Override - public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception