Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for reading unsigned int "i" #675

Merged
merged 2 commits into from
Mar 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/main/java/com/rabbitmq/client/impl/ValueReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ static Object readFieldValue(DataInputStream in)
case 'I':
value = in.readInt();
break;
case 'i':
value = readUnsignedInt(in);
break;
case 'D':
int scale = in.readUnsignedByte();
byte [] unscaled = new byte[4];
Expand Down Expand Up @@ -213,6 +216,19 @@ static Object readFieldValue(DataInputStream in)
return value;
}

/** Read an unsigned int */
private static long readUnsignedInt(DataInputStream in)
throws IOException
{
long ch1 = in.read();
long ch2 = in.read();
long ch3 = in.read();
long ch4 = in.read();
if ((ch1 | ch2 | ch3 | ch4) < 0)
throw new EOFException();
return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + ch4);
}

/** Read a field-array */
private static List<Object> readArray(DataInputStream in)
throws IOException
Expand Down