Skip to content

Commit 1a48bb7

Browse files
Correctly merge non-empty x-args that do not include queue type
Besides fixing a regression detected by priority_queue_SUITE, this introduces a drive-by change: rabbit_priority_queue: avoid an exception when max priority is a negative value that circumvented validation
1 parent f3b7a34 commit 1a48bb7

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

deps/rabbit/src/rabbit_amqqueue.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ assert_args_equivalence(Q, NewArgs) ->
805805
maybe_inject_default_queue_type_shortcut_into_args(Args0, DefaultQueueType) ->
806806
case rabbit_misc:table_lookup(Args0, <<"x-queue-type">>) of
807807
undefined ->
808-
inject_default_queue_type_shortcut_into_args([], DefaultQueueType);
808+
inject_default_queue_type_shortcut_into_args(Args0, DefaultQueueType);
809809
{longstr, undefined} ->
810810
%% Important: use a shortcut such as 'quorum' or 'stream' that for the given queue type module
811811
inject_default_queue_type_shortcut_into_args(Args0, DefaultQueueType);

deps/rabbit/src/rabbit_priority_queue.erl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@ priorities(Q) when ?is_amqqueue(Q) ->
129129
case lists:member(Type, Ints) of
130130
false -> none;
131131
true ->
132-
Max = min(RequestedMax, ?MAX_SUPPORTED_PRIORITY),
132+
%% make sure the value is no greater than ?MAX_SUPPORTED_PRIORITY but
133+
%% also is not negative
134+
Max = max(1, min(RequestedMax, ?MAX_SUPPORTED_PRIORITY)),
133135
lists:reverse(lists:seq(0, Max))
134136
end;
135137
_ -> none

0 commit comments

Comments
 (0)