Skip to content

Commit 5971e42

Browse files
authored
Add support for reading unsigned int "i"
Add support for reading unsigned int "I" https://www.rabbitmq.com/amqp-0-9-1-errata.html#section_3
1 parent 0c83dc2 commit 5971e42

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/main/java/com/rabbitmq/client/impl/ValueReader.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ static Object readFieldValue(DataInputStream in)
164164
case 'I':
165165
value = in.readInt();
166166
break;
167+
case 'i':
168+
value = readUnsignedInt(in);
169+
break;
167170
case 'D':
168171
int scale = in.readUnsignedByte();
169172
byte [] unscaled = new byte[4];
@@ -213,6 +216,17 @@ static Object readFieldValue(DataInputStream in)
213216
return value;
214217
}
215218

219+
/** Read an unsigned int */
220+
private static long readUnsignedInt(DataInputStream in) throws IOException {
221+
long ch1 = in.read();
222+
long ch2 = in.read();
223+
long ch3 = in.read();
224+
long ch4 = in.read();
225+
if ((ch1 | ch2 | ch3 | ch4) < 0)
226+
throw new EOFException();
227+
return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + ch4);
228+
}
229+
216230
/** Read a field-array */
217231
private static List<Object> readArray(DataInputStream in)
218232
throws IOException

0 commit comments

Comments
 (0)