From 41f8eb68c90b0e2ddb8a615f83ca94110669adcb Mon Sep 17 00:00:00 2001 From: NayXegp Date: Sun, 23 Sep 2018 03:26:17 +0200 Subject: [PATCH] #2529: Use single legacy kicker instance for all channels --- .../main/java/net/md_5/bungee/protocol/KickStringWriter.java | 2 ++ proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/KickStringWriter.java b/protocol/src/main/java/net/md_5/bungee/protocol/KickStringWriter.java index eda9571e..e2e34a34 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/KickStringWriter.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/KickStringWriter.java @@ -1,9 +1,11 @@ package net.md_5.bungee.protocol; import io.netty.buffer.ByteBuf; +import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.MessageToByteEncoder; +@ChannelHandler.Sharable public class KickStringWriter extends MessageToByteEncoder { diff --git a/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java b/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java index 551ae1e1..ffee7062 100644 --- a/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java +++ b/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java @@ -56,7 +56,7 @@ public class PipelineUtils ch.pipeline().addBefore( FRAME_DECODER, LEGACY_DECODER, new LegacyDecoder() ); ch.pipeline().addAfter( FRAME_DECODER, PACKET_DECODER, new MinecraftDecoder( Protocol.HANDSHAKE, true, ProxyServer.getInstance().getProtocolVersion() ) ); ch.pipeline().addAfter( FRAME_PREPENDER, PACKET_ENCODER, new MinecraftEncoder( Protocol.HANDSHAKE, true, ProxyServer.getInstance().getProtocolVersion() ) ); - ch.pipeline().addBefore( FRAME_PREPENDER, LEGACY_KICKER, new KickStringWriter() ); + ch.pipeline().addBefore( FRAME_PREPENDER, LEGACY_KICKER, legacyKicker ); ch.pipeline().get( HandlerBoss.class ).setHandler( new InitialHandler( BungeeCord.getInstance(), listener ) ); if ( listener.isProxyProtocol() ) @@ -66,6 +66,7 @@ public class PipelineUtils } }; public static final Base BASE = new Base(); + private static final KickStringWriter legacyKicker = new KickStringWriter(); private static final Varint21LengthFieldPrepender framePrepender = new Varint21LengthFieldPrepender(); public static final String TIMEOUT_HANDLER = "timeout"; public static final String PACKET_DECODER = "packet-decoder";