From 660c12676ed1169005a919c87309edd2b6efc180 Mon Sep 17 00:00:00 2001 From: Graham Date: Wed, 5 Jan 2022 21:12:53 +0000 Subject: [PATCH] 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 --- .../org/openrs2/game/net/login/LoginChannelHandler.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/game/src/main/kotlin/org/openrs2/game/net/login/LoginChannelHandler.kt b/game/src/main/kotlin/org/openrs2/game/net/login/LoginChannelHandler.kt index 17719c3e..33f5da19 100644 --- a/game/src/main/kotlin/org/openrs2/game/net/login/LoginChannelHandler.kt +++ b/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) + } } }