diff --git a/proxy/src/main/java/net/md_5/bungee/netty/ChannelWrapper.java b/proxy/src/main/java/net/md_5/bungee/netty/ChannelWrapper.java index 7867165e..072c9b51 100644 --- a/proxy/src/main/java/net/md_5/bungee/netty/ChannelWrapper.java +++ b/proxy/src/main/java/net/md_5/bungee/netty/ChannelWrapper.java @@ -1,6 +1,7 @@ package net.md_5.bungee.netty; import io.netty.channel.Channel; +import io.netty.channel.ChannelHandlerContext; import lombok.Getter; public class ChannelWrapper @@ -11,10 +12,10 @@ public class ChannelWrapper private volatile boolean closed; private final ReusableChannelPromise promise; - public ChannelWrapper(Channel ch) + public ChannelWrapper(ChannelHandlerContext ctx) { - this.ch = ch; - this.promise = new ReusableChannelPromise( ch ); + this.ch = ctx.channel(); + this.promise = new ReusableChannelPromise( ctx ); } public synchronized void write(Object packet) 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 e9f7f42a..6b26e5d9 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 @@ -6,13 +6,10 @@ import io.netty.channel.ChannelInboundMessageHandlerAdapter; import io.netty.handler.timeout.ReadTimeoutException; import java.io.IOException; import java.util.logging.Level; -import net.md_5.bungee.ServerConnector; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.connection.CancelSendSignal; -import net.md_5.bungee.connection.DownstreamBridge; import net.md_5.bungee.connection.InitialHandler; import net.md_5.bungee.connection.PingHandler; -import net.md_5.bungee.connection.UpstreamBridge; /** * This class is a primitive wrapper for {@link PacketHandler} instances tied to @@ -36,7 +33,7 @@ public class HandlerBoss extends ChannelInboundMessageHandlerAdapter { if ( handler != null ) { - channel = new ChannelWrapper( ctx.channel() ); + channel = new ChannelWrapper( ctx ); handler.connected( channel ); if ( !( handler instanceof InitialHandler || handler instanceof PingHandler ) ) diff --git a/proxy/src/main/java/net/md_5/bungee/netty/ReusableChannelPromise.java b/proxy/src/main/java/net/md_5/bungee/netty/ReusableChannelPromise.java index ae985f18..0ca04b87 100644 --- a/proxy/src/main/java/net/md_5/bungee/netty/ReusableChannelPromise.java +++ b/proxy/src/main/java/net/md_5/bungee/netty/ReusableChannelPromise.java @@ -1,9 +1,11 @@ package net.md_5.bungee.netty; import io.netty.channel.Channel; +import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelPromise; import io.netty.util.concurrent.Future; import io.netty.util.concurrent.GenericFutureListener; +import java.nio.channels.ClosedChannelException; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; @@ -15,12 +17,12 @@ import net.md_5.bungee.api.ProxyServer; public class ReusableChannelPromise implements ChannelPromise { - private final Channel ch; + private final ChannelHandlerContext ctx; @Override public Channel channel() { - return ch; + return ctx.channel(); } @Override @@ -44,6 +46,10 @@ public class ReusableChannelPromise implements ChannelPromise @Override public ChannelPromise setFailure(Throwable cause) { + if ( !( cause instanceof ClosedChannelException ) ) + { + ctx.fireExceptionCaught( cause ); + } return this; }