Skip to content

Commit b1064fd

Browse files
committed
Support negative integers in modified annotations
1 parent 2e90619 commit b1064fd

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

deps/amqp10_client/src/amqp10_client_session.erl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,8 +1178,13 @@ wrap_map_value(true) ->
11781178
{boolean, true};
11791179
wrap_map_value(false) ->
11801180
{boolean, false};
1181-
wrap_map_value(V) when is_integer(V) andalso V >= 0 ->
1182-
uint(V);
1181+
wrap_map_value(V) when is_integer(V) ->
1182+
case V < 0 of
1183+
true ->
1184+
{int, V};
1185+
false ->
1186+
uint(V)
1187+
end;
11831188
wrap_map_value(V) when is_binary(V) ->
11841189
utf8(V);
11851190
wrap_map_value(V) when is_list(V) ->

deps/rabbit/test/amqp_client_SUITE.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ modified_dead_letter_history(Config) ->
786786
#{<<"x-opt-history-list">> => {list, [{int, -99} | L1]},
787787
<<"x-opt-history-map">> => {map, [{{symbol, <<"k2">>}, {symbol, <<"v2">>}} | L2]},
788788
<<"x-opt-history-array">> => {array, utf8, [{utf8, <<"a2">>} | L0]},
789-
<<"x-other">> => 99}}),
789+
<<"x-other">> => -99}}),
790790

791791
{ok, Msg3} = amqp10_client:get_msg(Receiver1),
792792
?assertEqual([<<"m">>], amqp10_msg:body(Msg3)),
@@ -797,7 +797,7 @@ modified_dead_letter_history(Config) ->
797797
<<"x-opt-history-list">> := [{int, -99}, {utf8, <<"l1">>}],
798798
<<"x-opt-history-map">> := [{{symbol, <<"k2">>}, {symbol, <<"v2">>}},
799799
{{symbol, <<"k1">>}, {byte, -1}}],
800-
<<"x-other">> := 99}, amqp10_msg:message_annotations(Msg3)),
800+
<<"x-other">> := -99}, amqp10_msg:message_annotations(Msg3)),
801801
ok = amqp10_client:accept_msg(Receiver1, Msg3),
802802

803803
ok = detach_link_sync(Receiver1),

0 commit comments

Comments
 (0)