Utilize ByteBuf.readString()
This commit is contained in:
@@ -279,8 +279,7 @@ public enum ProtocolUtils {
|
|||||||
checkFrame(buf.isReadable(length),
|
checkFrame(buf.isReadable(length),
|
||||||
"Trying to read a string that is too long (wanted %s, only have %s)", length,
|
"Trying to read a string that is too long (wanted %s, only have %s)", length,
|
||||||
buf.readableBytes());
|
buf.readableBytes());
|
||||||
String str = buf.toString(buf.readerIndex(), length, StandardCharsets.UTF_8);
|
String str = buf.readString(length, StandardCharsets.UTF_8);
|
||||||
buf.skipBytes(length);
|
|
||||||
checkFrame(str.length() <= cap, "Got a too-long string (got %s, max %s)", str.length(), cap);
|
checkFrame(str.length() <= cap, "Got a too-long string (got %s, max %s)", str.length(), cap);
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user