Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public static final boolean isFixedArray(byte b)

public static final boolean isFixedMap(byte b)
{
return (b & (byte) 0xe0) == Code.FIXMAP_PREFIX;
return (b & (byte) 0xf0) == Code.FIXMAP_PREFIX;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch:)

}

public static final boolean isFixedRaw(byte b)
Expand Down
34 changes: 34 additions & 0 deletions msgpack-core/src/test/scala/org/msgpack/core/MessagePackTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,40 @@ class MessagePackTest extends MessagePackSpec {
}
}

"detect fixarray values" in {

val outputStream = new ByteArrayOutputStream
val packer = MessagePack.newDefaultPacker(outputStream)
packer.packArrayHeader(0)
packer.close
val bytes = outputStream.toByteArray
MessagePack.newDefaultUnpacker(bytes).unpackArrayHeader() shouldBe 0
try {
MessagePack.newDefaultUnpacker(bytes).unpackMapHeader()
fail("Shouldn't reach here")
}
catch {
case e: MessageTypeException => // OK
}
}

"detect fixmap values" in {

val outputStream = new ByteArrayOutputStream
val packer = MessagePack.newDefaultPacker(outputStream)
packer.packMapHeader(0)
packer.close
val bytes = outputStream.toByteArray
MessagePack.newDefaultUnpacker(bytes).unpackMapHeader() shouldBe 0
try {
MessagePack.newDefaultUnpacker(bytes).unpackArrayHeader()
fail("Shouldn't reach here")
}
catch {
case e: MessageTypeException => // OK
}
}

"detect fixint quickly" in {

val N = 100000
Expand Down