Skip to content

Commit 79a572b

Browse files
committed
Resolve race condition when injecting
1 parent 57fe178 commit 79a572b

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

spigot/src/main/java/org/geysermc/floodgate/inject/spigot/SpigotInjector.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,16 +110,19 @@ public void injectClient(ChannelFuture future) {
110110
future.channel().pipeline().addFirst("floodgate-init", new ChannelInboundHandlerAdapter() {
111111
@Override
112112
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
113-
super.channelRead(ctx, msg);
114-
115113
Channel channel = (Channel) msg;
116-
channel.pipeline().addLast(new ChannelInitializer<Channel>() {
114+
// add first worked as well
115+
channel.pipeline().addLast("floodgate-injector", new ChannelInboundHandlerAdapter() {
117116
@Override
118-
protected void initChannel(Channel channel) {
119-
injectAddonsCall(channel, false);
120-
addInjectedClient(channel);
117+
public void channelActive(ChannelHandlerContext childCtx) throws Exception {
118+
injectAddonsCall(childCtx.channel(), false);
119+
addInjectedClient(childCtx.channel());
120+
childCtx.pipeline().remove(this);
121+
super.channelActive(childCtx);
121122
}
122123
});
124+
125+
super.channelRead(ctx, msg);
123126
}
124127
});
125128
}

0 commit comments

Comments
 (0)