Only remove handlers from pipeline if future is successful

If the future is not successful the channel may have been closed. The
pipeline of a closed channel is empty, so attempting to remove handlers
from it would cause an exception.

Signed-off-by: Graham <gpe@openrs2.org>
bzip2
Graham 3 years ago
parent 207b99d937
commit 660c12676e
  1. 4
      game/src/main/kotlin/org/openrs2/game/net/login/LoginChannelHandler.kt

@ -61,11 +61,13 @@ public class LoginChannelHandler @Inject constructor(
) )
ctx.pipeline().remove(Rs2Decoder::class.java) ctx.pipeline().remove(Rs2Decoder::class.java)
ctx.write(LoginResponse.Js5Ok).addListener { ctx.write(LoginResponse.Js5Ok).addListener { future ->
if (future.isSuccess) {
ctx.pipeline().remove(Rs2Encoder::class.java) ctx.pipeline().remove(Rs2Encoder::class.java)
ctx.pipeline().remove(this) ctx.pipeline().remove(this)
} }
} }
}
private fun handleInitJaggrabConnection(ctx: ChannelHandlerContext) { private fun handleInitJaggrabConnection(ctx: ChannelHandlerContext) {
ctx.pipeline().addLast( ctx.pipeline().addLast(

Loading…
Cancel
Save