From fbb9694feb7a498424f6eb8061e2711c99cc5e46 Mon Sep 17 00:00:00 2001 From: Graham Date: Sun, 16 May 2021 14:22:47 +0100 Subject: [PATCH] Close JS5 connection if an invalid file is requested This mimics the behaviour of the OSRS server. Signed-off-by: Graham --- .../org/openrs2/game/net/js5/Js5Service.kt | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/game/src/main/kotlin/org/openrs2/game/net/js5/Js5Service.kt b/game/src/main/kotlin/org/openrs2/game/net/js5/Js5Service.kt index 6dabb0a2..9865670b 100644 --- a/game/src/main/kotlin/org/openrs2/game/net/js5/Js5Service.kt +++ b/game/src/main/kotlin/org/openrs2/game/net/js5/Js5Service.kt @@ -12,6 +12,7 @@ import org.openrs2.cache.VersionTrailer import org.openrs2.protocol.js5.Js5Request import org.openrs2.protocol.js5.Js5Response import org.openrs2.util.collect.UniqueQueue +import java.io.FileNotFoundException import javax.inject.Inject import javax.inject.Singleton @@ -66,12 +67,17 @@ public class Js5Service @Inject constructor( } } } else { - store.read(request.archive, request.group).use { buf -> - if (request.archive != Js5Archive.ARCHIVESET) { - VersionTrailer.strip(buf) - } + try { + store.read(request.archive, request.group).use { buf -> + if (request.archive != Js5Archive.ARCHIVESET) { + VersionTrailer.strip(buf) + } - buf.retain() + buf.retain() + } + } catch (ex: FileNotFoundException) { + ctx.close() + return } }