File tree Expand file tree Collapse file tree 2 files changed +35
-1
lines changed
main/java/org/msgpack/core
test/scala/org/msgpack/core Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -234,7 +234,7 @@ public static final boolean isFixedArray(byte b)
234234
235235 public static final boolean isFixedMap (byte b )
236236 {
237- return (b & (byte ) 0xe0 ) == Code .FIXMAP_PREFIX ;
237+ return (b & (byte ) 0xf0 ) == Code .FIXMAP_PREFIX ;
238238 }
239239
240240 public static final boolean isFixedRaw (byte b )
Original file line number Diff line number Diff line change @@ -59,6 +59,40 @@ class MessagePackTest extends MessagePackSpec {
5959 }
6060 }
6161
62+ " detect fixarray values" in {
63+
64+ val outputStream = new ByteArrayOutputStream
65+ val packer = MessagePack .newDefaultPacker(outputStream)
66+ packer.packArrayHeader(0 )
67+ packer.close
68+ val bytes = outputStream.toByteArray
69+ MessagePack .newDefaultUnpacker(bytes).unpackArrayHeader() shouldBe 0
70+ try {
71+ MessagePack .newDefaultUnpacker(bytes).unpackMapHeader()
72+ fail(" Shouldn't reach here" )
73+ }
74+ catch {
75+ case e : MessageTypeException => // OK
76+ }
77+ }
78+
79+ " detect fixmap values" in {
80+
81+ val outputStream = new ByteArrayOutputStream
82+ val packer = MessagePack .newDefaultPacker(outputStream)
83+ packer.packMapHeader(0 )
84+ packer.close
85+ val bytes = outputStream.toByteArray
86+ MessagePack .newDefaultUnpacker(bytes).unpackMapHeader() shouldBe 0
87+ try {
88+ MessagePack .newDefaultUnpacker(bytes).unpackArrayHeader()
89+ fail(" Shouldn't reach here" )
90+ }
91+ catch {
92+ case e : MessageTypeException => // OK
93+ }
94+ }
95+
6296 " detect fixint quickly" in {
6397
6498 val N = 100000
You can’t perform that action at this time.
0 commit comments