Commit 22096a9f authored by Him188's avatar Him188

Fix bugs

parent 25b162a0
...@@ -37,7 +37,7 @@ class ContactList<C : Contact>(@MiraiInternalAPI val delegate: LockFreeLinkedLis ...@@ -37,7 +37,7 @@ class ContactList<C : Contact>(@MiraiInternalAPI val delegate: LockFreeLinkedLis
operator fun <C : Contact> LockFreeLinkedList<C>.get(id: Long): C { operator fun <C : Contact> LockFreeLinkedList<C>.get(id: Long): C {
forEach { if (it.id == id) return it } forEach { if (it.id == id) return it }
throw NoSuchElementException("No such contact with id $id") throw NoSuchElementException("No such contact: $id")
} }
fun <C : Contact> LockFreeLinkedList<C>.getOrNull(id: Long): C? { fun <C : Contact> LockFreeLinkedList<C>.getOrNull(id: Long): C? {
......
...@@ -114,6 +114,8 @@ fun Input.readTLVMap(expectingEOF: Boolean = true, tagSize: Int, suppressDuplica ...@@ -114,6 +114,8 @@ fun Input.readTLVMap(expectingEOF: Boolean = true, tagSize: Int, suppressDuplica
duplicating value=${this.readUShortLVByteArray().toUHexString()} duplicating value=${this.readUShortLVByteArray().toUHexString()}
""".trimIndent() """.trimIndent()
) )
} else {
this.discardExact(this.readShort().toInt() and 0xffff)
} }
} else { } else {
try { try {
......
...@@ -23,7 +23,11 @@ actual class PlatformSocket : Closeable { ...@@ -23,7 +23,11 @@ actual class PlatformSocket : Closeable {
actual val isOpen: Boolean actual val isOpen: Boolean
get() = socket.isConnected get() = socket.isConnected
override fun close() = socket.close() override fun close() {
if (::socket.isInitialized) {
socket.close()
}
}
@PublishedApi @PublishedApi
internal lateinit var writeChannel: BufferedOutputStream internal lateinit var writeChannel: BufferedOutputStream
......
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