Skip to content

Commit 394d896

Browse files
Merge pull request #675 from gustf/patch-2
Add support for reading unsigned int "i"
2 parents 0c83dc2 + 4895aa2 commit 394d896

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

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

Lines changed: 16 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,19 @@ static Object readFieldValue(DataInputStream in)
213216
return value;
214217
}
215218

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

0 commit comments

Comments
 (0)