diff --git a/rsocket-broker-frames/src/main/java/io/rsocket/broker/frames/FlyweightUtils.java b/rsocket-broker-frames/src/main/java/io/rsocket/broker/frames/FlyweightUtils.java index d560e8a..0cafd60 100644 --- a/rsocket-broker-frames/src/main/java/io/rsocket/broker/frames/FlyweightUtils.java +++ b/rsocket-broker-frames/src/main/java/io/rsocket/broker/frames/FlyweightUtils.java @@ -36,6 +36,7 @@ static void encodeByteString(ByteBuf byteBuf, String s) { static String decodeByteString(ByteBuf byteBuf, int offset) { int length = byteBuf.getByte(offset); + length &= UNSIGNED_BYTE_MAX_VALUE; offset += Byte.BYTES; return byteBuf.toString(offset, length, StandardCharsets.UTF_8); @@ -43,6 +44,7 @@ static String decodeByteString(ByteBuf byteBuf, int offset) { static int decodeByteStringLength(ByteBuf byteBuf, int offset) { int length = byteBuf.getByte(offset); + length &= UNSIGNED_BYTE_MAX_VALUE; return Byte.BYTES + length; }