Skip to content

Commit 33f9ccf

Browse files
committed
Changed the extension type interface to use byte
1 parent 9e8c806 commit 33f9ccf

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

msgpack-core/src/main/java/org/msgpack/core/MessagePacker.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -477,41 +477,41 @@ public MessagePacker packValue(Value v) throws IOException {
477477
return this;
478478
}
479479

480-
public MessagePacker packExtensionTypeHeader(int extType, int payloadLen) throws IOException {
480+
public MessagePacker packExtensionTypeHeader(byte extType, int payloadLen) throws IOException {
481481
if(payloadLen < (1 << 8)) {
482482
if(payloadLen > 0 && (payloadLen & (payloadLen - 1)) == 0) { // check whether dataLen == 2^x
483483
if(payloadLen == 1) {
484-
writeByteAndByte(FIXEXT1, (byte) extType);
484+
writeByteAndByte(FIXEXT1, extType);
485485
}
486486
else if(payloadLen == 2) {
487-
writeByteAndByte(FIXEXT2, (byte) extType);
487+
writeByteAndByte(FIXEXT2, extType);
488488
}
489489
else if(payloadLen == 4) {
490-
writeByteAndByte(FIXEXT4, (byte) extType);
490+
writeByteAndByte(FIXEXT4, extType);
491491
}
492492
else if(payloadLen == 8) {
493-
writeByteAndByte(FIXEXT8, (byte) extType);
493+
writeByteAndByte(FIXEXT8, extType);
494494
}
495495
else if(payloadLen == 16) {
496-
writeByteAndByte(FIXEXT16, (byte) extType);
496+
writeByteAndByte(FIXEXT16, extType);
497497
}
498498
else {
499499
writeByteAndByte(EXT8, (byte) payloadLen);
500-
writeByte((byte) extType);
500+
writeByte(extType);
501501
}
502502
}
503503
else {
504504
writeByteAndByte(EXT8, (byte) payloadLen);
505-
writeByte((byte) extType);
505+
writeByte(extType);
506506
}
507507
}
508508
else if(payloadLen < (1 << 16)) {
509509
writeByteAndShort(EXT16, (short) payloadLen);
510-
writeByte((byte) extType);
510+
writeByte(extType);
511511
}
512512
else {
513513
writeByteAndInt(EXT32, payloadLen);
514-
writeByte((byte) extType);
514+
writeByte(extType);
515515

516516
// TODO support dataLen > 2^31 - 1
517517
}

msgpack-core/src/main/java/org/msgpack/core/example/MessagePackExample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public static void packer() throws IOException {
125125

126126
// Write ext type data: https://github.com/msgpack/msgpack/blob/master/spec.md#ext-format-family
127127
byte[] extData = "custom data type".getBytes(MessagePack.UTF8);
128-
packer.packExtensionTypeHeader(1, 10); // type number [0, 127], data byte length
128+
packer.packExtensionTypeHeader((byte) 1, 10); // type number [0, 127], data byte length
129129
packer.writePayload(extData);
130130

131131
// Succinct syntax for packing

msgpack-jackson/src/test/java/org/msgpack/jackson/dataformat/MessagePackParserTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public void testParserShouldReadObject() throws IOException {
6767
// #9
6868
byte[] extPayload = {-80, -50, -25, -114, -25, 16, 60, 68};
6969
packer.packString("ext");
70-
packer.packExtensionTypeHeader(0, extPayload.length);
70+
packer.packExtensionTypeHeader((byte) 0, extPayload.length);
7171
packer.writePayload(extPayload);
7272

7373
packer.flush();
@@ -191,7 +191,7 @@ public void testParserShouldReadArray() throws IOException {
191191
packer.packBoolean(true);
192192
// #11
193193
byte[] extPayload = {-80, -50, -25, -114, -25, 16, 60, 68};
194-
packer.packExtensionTypeHeader(-1, extPayload.length);
194+
packer.packExtensionTypeHeader((byte) -1, extPayload.length);
195195
packer.writePayload(extPayload);
196196

197197
packer.flush();

0 commit comments

Comments
 (0)