From 5971e42e97f80df4d0228a6a9669c8c1a4d725cd Mon Sep 17 00:00:00 2001 From: Gustaf Andersson Date: Mon, 22 Mar 2021 16:00:21 +0100 Subject: [PATCH 1/2] 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 --- .../java/com/rabbitmq/client/impl/ValueReader.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/java/com/rabbitmq/client/impl/ValueReader.java b/src/main/java/com/rabbitmq/client/impl/ValueReader.java index 3e80f8853e..4912c8541d 100644 --- a/src/main/java/com/rabbitmq/client/impl/ValueReader.java +++ b/src/main/java/com/rabbitmq/client/impl/ValueReader.java @@ -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]; @@ -213,6 +216,17 @@ 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 readArray(DataInputStream in) throws IOException From 4895aa2d6d5d5774674075663ea6fa751e48e86e Mon Sep 17 00:00:00 2001 From: Gustaf Andersson Date: Mon, 22 Mar 2021 16:07:36 +0100 Subject: [PATCH 2/2] code style --- src/main/java/com/rabbitmq/client/impl/ValueReader.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/rabbitmq/client/impl/ValueReader.java b/src/main/java/com/rabbitmq/client/impl/ValueReader.java index 4912c8541d..7c708f73d2 100644 --- a/src/main/java/com/rabbitmq/client/impl/ValueReader.java +++ b/src/main/java/com/rabbitmq/client/impl/ValueReader.java @@ -217,7 +217,9 @@ static Object readFieldValue(DataInputStream in) } /** Read an unsigned int */ - private static long readUnsignedInt(DataInputStream in) throws IOException { + private static long readUnsignedInt(DataInputStream in) + throws IOException + { long ch1 = in.read(); long ch2 = in.read(); long ch3 = in.read();