Commit 432a8690 authored by Him188's avatar Him188

Fix structure end reading

parent db7d0e83
...@@ -308,10 +308,10 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo ...@@ -308,10 +308,10 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
input: JceInput input: JceInput
) : JceDecoder(input) { ) : JceDecoder(input) {
override fun endStructure(desc: SerialDescriptor) { override fun endStructure(desc: SerialDescriptor) {
while (input.peakHead().type != STRUCT_END) { while (input.input.canRead() && input.peakHeadOrNull()?.type != STRUCT_END) {
input.readHead() input.readHeadOrNull() ?: return
} }
input.readHead() input.readHeadOrNull()
} }
} }
...@@ -513,6 +513,9 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo ...@@ -513,6 +513,9 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
@PublishedApi @PublishedApi
internal fun peakHead(): JceHead = input.makeView().readHead() ?: error("no enough data to read head") internal fun peakHead(): JceHead = input.makeView().readHead() ?: error("no enough data to read head")
@PublishedApi
internal fun peakHeadOrNull(): JceHead? = input.makeView().readHead()
@Suppress("NOTHING_TO_INLINE") // 避免 stacktrace 出现两个 readHead @Suppress("NOTHING_TO_INLINE") // 避免 stacktrace 出现两个 readHead
private inline fun IoBuffer.readHead(): JceHead? { private inline fun IoBuffer.readHead(): JceHead? {
if (endOfInput) return null if (endOfInput) return null
......
...@@ -349,7 +349,7 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler ...@@ -349,7 +349,7 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
// 不要 `withTimeout`. timeout 的异常会不知道去哪了. // 不要 `withTimeout`. timeout 的异常会不知道去哪了.
} ?: net.mamoe.mirai.qqandroid.utils.inline { } ?: net.mamoe.mirai.qqandroid.utils.inline {
packetListeners.remove(handler) packetListeners.remove(handler)
error("timeout when sending $commandName") error("timeout when receiving response of $commandName")
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment