Skip to content

Commit a0dcfe4

Browse files
author
Matthew Sackman
committed
Comparison of RabbitMQ.Client.Impl.WireFormatting and ValueReader.java and ValueWriter.java shows that the only missing check in the Java client is the check on writing out a shortstr. Fixed. Also, one grammar mistake.
1 parent 9f32b66 commit a0dcfe4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/com/rabbitmq/client/impl/ValueWriter.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ public final void writeShortstr(String str)
5959
throws IOException
6060
{
6161
byte [] bytes = str.getBytes("utf-8");
62+
int length = bytes.length;
63+
if (length > 255) {
64+
throw new IllegalArgumentException(
65+
"Short string too long; utf-8 encoded length = " + length +
66+
", max = 255.");
67+
}
6268
out.writeByte(bytes.length);
6369
out.write(bytes);
6470
}
@@ -91,7 +97,7 @@ public final void writeShort(int s)
9197
public final void writeLong(int l)
9298
throws IOException
9399
{
94-
// java's arithmetic on this type is signed, however its
100+
// java's arithmetic on this type is signed, however it's
95101
// reasonable to use ints to represent the unsigned long
96102
// type - for values < Integer.MAX_VALUE everything works
97103
// as expected

0 commit comments

Comments
 (0)