From a640f74dc8d5dcd667fd9154bb323765fbf3e863 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Mon, 17 Mar 2014 12:28:21 +0000 Subject: [PATCH] change AMQP codec field type 'b' interpretation from unsigned to signed, in compliance with the spec and most clients. --- src/rabbit_binary_generator.erl | 2 +- src/rabbit_binary_parser.erl | 2 +- src/rabbit_tests.erl | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/rabbit_binary_generator.erl b/src/rabbit_binary_generator.erl index 83f68ed34ea6..1e5ab0a7b2a0 100644 --- a/src/rabbit_binary_generator.erl +++ b/src/rabbit_binary_generator.erl @@ -126,7 +126,7 @@ field_value_to_binary(decimal, V) -> {Before, After} = V, field_value_to_binary(timestamp, V) -> [$T, <>]; field_value_to_binary(table, V) -> [$F | table_to_binary(V)]; field_value_to_binary(array, V) -> [$A | array_to_binary(V)]; -field_value_to_binary(byte, V) -> [$b, <>]; +field_value_to_binary(byte, V) -> [$b, <>]; field_value_to_binary(double, V) -> [$d, <>]; field_value_to_binary(float, V) -> [$f, <>]; field_value_to_binary(long, V) -> [$l, <>]; diff --git a/src/rabbit_binary_parser.erl b/src/rabbit_binary_parser.erl index f65d8ea7fdbb..9ffeb41a1906 100644 --- a/src/rabbit_binary_parser.erl +++ b/src/rabbit_binary_parser.erl @@ -71,7 +71,7 @@ parse_field_value(<<$F, VLen:32/unsigned, Table:VLen/binary, R/binary>>) -> parse_field_value(<<$A, VLen:32/unsigned, Array:VLen/binary, R/binary>>) -> {array, parse_array(Array), R}; -parse_field_value(<<$b, V:8/unsigned, R/binary>>) -> {byte, V, R}; +parse_field_value(<<$b, V:8/signed, R/binary>>) -> {byte, V, R}; parse_field_value(<<$d, V:64/float, R/binary>>) -> {double, V, R}; parse_field_value(<<$f, V:32/float, R/binary>>) -> {float, V, R}; parse_field_value(<<$l, V:64/signed, R/binary>>) -> {long, V, R}; diff --git a/src/rabbit_tests.erl b/src/rabbit_tests.erl index 1552d1ec3fb7..b56aa805d543 100644 --- a/src/rabbit_tests.erl +++ b/src/rabbit_tests.erl @@ -429,7 +429,7 @@ test_table_codec() -> {<<"table">>, table, [{<<"one">>, signedint, 54321}, {<<"two">>, longstr, <<"A long string">>}]}, - {<<"byte">>, byte, 255}, + {<<"byte">>, byte, -128}, {<<"long">>, long, 1234567890}, {<<"short">>, short, 655}, {<<"bool">>, bool, true}, @@ -446,7 +446,7 @@ test_table_codec() -> 5,"table", "F", 31:32, % length of table 3,"one", "I", 54321:32, 3,"two", "S", 13:32, "A long string", - 4,"byte", "b", 255:8, + 4,"byte", "b", -128:8/signed, 4,"long", "l", 1234567890:64, 5,"short", "s", 655:16, 4,"bool", "t", 1,