Commit 1aafe78b authored by Him188's avatar Him188

Fix java.nio.BufferUnderflowException

parent f7710775
...@@ -67,7 +67,7 @@ fun Input.readTLVMap(expectingEOF: Boolean = false, tagSize: Int = 1): MutableMa ...@@ -67,7 +67,7 @@ fun Input.readTLVMap(expectingEOF: Boolean = false, tagSize: Int = 1): MutableMa
2 -> readUShort() 2 -> readUShort()
else -> error("Unsupported tag size: $tagSize") else -> error("Unsupported tag size: $tagSize")
} }
} catch (e: EOFException) { } catch (e: Exception) { // java.nio.BufferUnderflowException is not a EOFException...
if (expectingEOF) { if (expectingEOF) {
return map return map
} }
...@@ -79,7 +79,7 @@ fun Input.readTLVMap(expectingEOF: Boolean = false, tagSize: Int = 1): MutableMa ...@@ -79,7 +79,7 @@ fun Input.readTLVMap(expectingEOF: Boolean = false, tagSize: Int = 1): MutableMa
check(!map.containsKey(type.toUInt())) { check(!map.containsKey(type.toUInt())) {
"Count not readTLVMap: duplicated key 0x${type.toUInt().toUHexString("")}. " + "Count not readTLVMap: duplicated key 0x${type.toUInt().toUHexString("")}. " +
"map=$map" + "map=$map" +
", duplicating value=${this.readUShortLVByteArray()}" + ", duplicating value=${this.readUShortLVByteArray().toUHexString()}" +
", remaining=" + if (expectingEOF) this.readBytes().toUHexString() else "[Not expecting EOF]" ", remaining=" + if (expectingEOF) this.readBytes().toUHexString() else "[Not expecting EOF]"
} }
try { try {
......
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