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. 8
      game/src/main/kotlin/org/openrs2/game/net/login/LoginChannelHandler.kt

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

Loading…
Cancel
Save