Skip to content

Commit

Permalink
Fix function clause crashes
Browse files Browse the repository at this point in the history
Fix failing tests in the MQTT shared_SUITE:
A classic queue message ID can be undefined as set in
https://github.com/rabbitmq/rabbitmq-server/blob/fbe79ff47b4edbc0fd95457e623d6593161ad198/deps/rabbit/src/rabbit_classic_queue_index_v2.erl#L1048

Fix failing tests in the MQTT shared_SUITE-mixed:
When feature flag message_containers is disabled, the
message is not an #mc{} record, but a #basic_message{} record.
  • Loading branch information
ansd committed Jun 29, 2023
1 parent a660fcb commit dbc9b84
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 20 deletions.
16 changes: 0 additions & 16 deletions deps/rabbit/src/mc_compat.erl
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,6 @@ get_annotation(exchange, #basic_message{exchange_name = Ex}) ->
Ex#resource.name;
get_annotation(id, #basic_message{id = Id}) ->
Id.
% get_annotation(binding_keys = Key,
% #basic_message{content =
% #content{properties =
% #'P_basic'{headers = H}}}) ->
% case H of
% undefined -> H;
% _ -> case rabbit_misc:table_lookup(H, Key) of
% {array, BKeys} -> [BKey || {longstr, BKey} <- BKeys];
% Undefined -> Undefined
% end
% end.

set_annotation(id, Value, #basic_message{} = Msg) ->
Msg#basic_message{id = Value};
Expand Down Expand Up @@ -93,11 +82,6 @@ set_annotation(<<"x-", _/binary>> = Key, Value,
C = C0#content{properties = B#'P_basic'{headers = H},
properties_bin = none},
Msg#basic_message{content = C}.
% set_annotation(binding_keys, BindingKeys, #basic_message{} = Msg) ->
% L = maps:fold(fun(B, true, Acc) ->
% [{longstr, B} | Acc]
% end, [], BindingKeys),
% rabbit_basic:add_header(<<"x-binding-keys">>, array, L, Msg).

is_persistent(#basic_message{content = Content}) ->
get_property(durable, Content).
Expand Down
9 changes: 5 additions & 4 deletions deps/rabbit/src/rabbit_variable_queue.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1285,9 +1285,9 @@ msg_status(Version, IsPersistent, IsDelivered, SeqId,
persist_to = determine_persist_to(Version, Msg, MsgProps, IndexMaxSize),
msg_props = MsgProps}.

beta_msg_status({Msg,
SeqId, MsgLocation, MsgProps, IsPersistent})
when element(1, Msg) == mc ->
beta_msg_status({Msg, SeqId, MsgLocation, MsgProps, IsPersistent})
when element(1, Msg) == mc orelse
is_record(Msg, basic_message) ->
MsgId = mc:get_annotation(id, Msg),
MS0 = beta_msg_status0(SeqId, MsgProps, IsPersistent),
MS0#msg_status{msg_id = MsgId,
Expand All @@ -1303,7 +1303,8 @@ beta_msg_status({Msg,
end};

beta_msg_status({MsgId, SeqId, MsgLocation, MsgProps, IsPersistent})
when is_binary(MsgId) ->
when is_binary(MsgId) orelse
MsgId =:= undefined ->
MS0 = beta_msg_status0(SeqId, MsgProps, IsPersistent),
MS0#msg_status{msg_id = MsgId,
msg = undefined,
Expand Down

0 comments on commit dbc9b84

Please sign in to comment.