mirror of
https://github.com/SpigotMC/BungeeCord.git
synced 2024-11-08 19:50:27 +01:00
Tweak our channel promise to be a bit more hellpful on errors
This commit is contained in:
parent
78e67283cc
commit
12cba14657
@ -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)
|
||||
|
@ -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<Object>
|
||||
{
|
||||
if ( handler != null )
|
||||
{
|
||||
channel = new ChannelWrapper( ctx.channel() );
|
||||
channel = new ChannelWrapper( ctx );
|
||||
handler.connected( channel );
|
||||
|
||||
if ( !( handler instanceof InitialHandler || handler instanceof PingHandler ) )
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user