Skip to content

Commit 377c820

Browse files
committed
queue_topology should not return undefined for members
it's easier to deal with the result if members is an empty list than when it is either a list or `undefined`.
1 parent 959449c commit 377c820

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

deps/rabbit/src/rabbit_amqp_management.erl

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -440,13 +440,9 @@ encode_queue(Q, NumMsgs, NumConsumers) ->
440440
{{utf8, <<"type">>}, {utf8, rabbit_queue_type:to_binary(QType)}},
441441
{{utf8, <<"arguments">>}, QArgs}
442442
],
443-
KVList1 = if is_list(Replicas) ->
444-
[{{utf8, <<"replicas">>},
445-
{array, utf8, [{utf8, atom_to_binary(R)} || R <- Replicas]}
446-
} | KVList0];
447-
Replicas =:= undefined ->
448-
KVList0
449-
end,
443+
KVList1 = [{{utf8, <<"replicas">>},
444+
{array, utf8, [{utf8, atom_to_binary(R)} || R <- Replicas]}
445+
} | KVList0],
450446
KVList = case Leader of
451447
undefined ->
452448
KVList1;
@@ -459,7 +455,7 @@ encode_queue(Q, NumMsgs, NumConsumers) ->
459455

460456
%% The returned Replicas contain both online and offline replicas.
461457
-spec queue_topology(amqqueue:amqqueue()) ->
462-
{Leader :: undefined | node(), Replicas :: undefined | [node(),...]}.
458+
{Leader :: undefined | node(), Replicas :: [node(),...]}.
463459
queue_topology(Q) ->
464460
Type = amqqueue:get_type(Q),
465461
Type:queue_topology(Q).

deps/rabbit/src/rabbit_queue_type.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@
275275
ok.
276276

277277
-callback queue_topology(amqqueue:amqqueue()) ->
278-
{Leader :: undefined | node(), Replicas :: undefined | [node(),...]}.
278+
{Leader :: undefined | node(), Replicas :: [node(),...]}.
279279

280280
-spec discover(binary() | atom()) -> queue_type().
281281
discover(<<"undefined">>) ->

deps/rabbitmq_mqtt/src/rabbit_mqtt_qos0_queue.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ state_info(A1) ->
305305
?UNSUPPORTED([A1]).
306306

307307
-spec queue_topology(amqqueue:amqqueue()) ->
308-
{Leader :: undefined | node(), Replicas :: undefined | [node(),...]}.
308+
{Leader :: undefined | node(), Replicas :: [node(),...]}.
309309
queue_topology(Q) ->
310310
Pid = amqqueue:get_pid(Q),
311311
Node = node(Pid),

0 commit comments

Comments
 (0)