Skip to content

Commit f555188

Browse files
[ci skip] Print correct max read length in StringType sanity checks (ViaVersion#4456)
1 parent 93d6fa2 commit f555188

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

api/src/main/java/com/viaversion/viaversion/api/type/types/StringType.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,21 @@ public String read(ByteBuf buffer) {
4949
int len = Types.VAR_INT.readPrimitive(buffer);
5050

5151
Preconditions.checkArgument(len <= maxLength * MAX_CHAR_UTF_8_LENGTH,
52-
"Cannot receive string longer than Short.MAX_VALUE * " + MAX_CHAR_UTF_8_LENGTH + " bytes (got %s bytes)", len);
52+
"Cannot receive string longer than " + maxLength + " * " + MAX_CHAR_UTF_8_LENGTH + " bytes (got %s bytes)", len);
5353

5454
String string = buffer.toString(buffer.readerIndex(), len, StandardCharsets.UTF_8);
5555
buffer.skipBytes(len);
5656

5757
Preconditions.checkArgument(string.length() <= maxLength,
58-
"Cannot receive string longer than Short.MAX_VALUE characters (got %s bytes)", string.length());
58+
"Cannot receive string longer than " + maxLength + " characters (got %s bytes)", string.length());
5959

6060
return string;
6161
}
6262

6363
@Override
6464
public void write(ByteBuf buffer, String object) {
6565
if (object.length() > maxLength) {
66-
throw new IllegalArgumentException("Cannot send string longer than Short.MAX_VALUE characters (got " + object.length() + " characters)");
66+
throw new IllegalArgumentException("Cannot send string longer than " + maxLength + " characters (got " + object.length() + " characters)");
6767
}
6868

6969
byte[] b = object.getBytes(StandardCharsets.UTF_8);

0 commit comments

Comments
 (0)