From 84fb928764602b547a86ba7711ccbe0d82d43595 Mon Sep 17 00:00:00 2001 From: Him188 Date: Mon, 7 Jun 2021 17:47:40 +0800 Subject: [PATCH] Add check for arguments of `NetworkHandlerSupport.sendAndExpect` --- .../commonMain/kotlin/network/handler/NetworkHandlerSupport.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/mirai-core/src/commonMain/kotlin/network/handler/NetworkHandlerSupport.kt b/mirai-core/src/commonMain/kotlin/network/handler/NetworkHandlerSupport.kt index 3e4d9e913..7afe0f993 100644 --- a/mirai-core/src/commonMain/kotlin/network/handler/NetworkHandlerSupport.kt +++ b/mirai-core/src/commonMain/kotlin/network/handler/NetworkHandlerSupport.kt @@ -88,6 +88,7 @@ internal abstract class NetworkHandlerSupport( } final override suspend fun sendAndExpect(packet: OutgoingPacket, timeout: Long, attempts: Int): Packet? { + require(attempts >= 1) { "attempts must be at least 1." } val listener = PacketListener(packet.commandName, packet.sequenceId) withExceptionCollector { repeat(attempts) {