Skip to content

Commit 8838266

Browse files
committed
Fix modified annotations
``` <field name="message-annotations" type="fields"/> ``` Prior to this commit integration tests succeeded because both Erlang client and RabbitMQ server contained a bug. This bug was noticed by a Java client test suite. (cherry picked from commit cd600be)
1 parent 2027864 commit 8838266

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

deps/amqp10_client/src/amqp10_client_session.erl

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,16 +1171,13 @@ make_link_ref(Role, Session, Handle) ->
11711171
#link_ref{role = Role, session = Session, link_handle = Handle}.
11721172

11731173
translate_message_annotations(MA)
1174-
when is_map(MA) andalso
1175-
map_size(MA) > 0 ->
1176-
Content = maps:fold(fun (K, V, Acc) ->
1177-
[{sym(K), wrap_map_value(V)} | Acc]
1178-
end, [], MA),
1179-
#'v1_0.message_annotations'{content = Content};
1174+
when map_size(MA) > 0 ->
1175+
{map, maps:fold(fun(K, V, Acc) ->
1176+
[{sym(K), wrap_map_value(V)} | Acc]
1177+
end, [], MA)};
11801178
translate_message_annotations(_MA) ->
11811179
undefined.
11821180

1183-
11841181
wrap_map_value(true) ->
11851182
{boolean, true};
11861183
wrap_map_value(false) ->

deps/rabbit/src/rabbit_amqp_session.erl

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1912,13 +1912,15 @@ settle_op_from_outcome(#'v1_0.modified'{delivery_failed = DelFailed,
19121912
undeliverable_here = UndelHere,
19131913
message_annotations = Anns0}) ->
19141914
Anns = case Anns0 of
1915-
#'v1_0.message_annotations'{content = C} ->
1916-
Anns1 = lists:map(fun({{symbol, K}, V}) ->
1917-
{K, unwrap(V)}
1918-
end, C),
1919-
maps:from_list(Anns1);
1920-
_ ->
1921-
#{}
1915+
undefined ->
1916+
#{};
1917+
{map, KVList} ->
1918+
Anns1 = lists:map(
1919+
%% "all symbolic keys except those beginning with "x-" are reserved." [3.2.10]
1920+
fun({{symbol, <<"x-", _/binary>> = K}, V}) ->
1921+
{K, unwrap(V)}
1922+
end, KVList),
1923+
maps:from_list(Anns1)
19221924
end,
19231925
{modify,
19241926
default(DelFailed, false),

0 commit comments

Comments
 (0)