summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Lebedeff <alebedev@mirantis.com>2016-03-23 17:49:07 +0300
committerMichael Klishin <mklishin@pivotal.io>2016-03-24 13:56:47 +0300
commit4932f7dbf3ca279f2d2194ca2266428852a16e08 (patch)
treedf0d0c892b6ff1c5e9202a219f067367aa21bc44
parentaf67b9554059568dcef1bd05224ba84324ec817b (diff)
downloadrabbitmq-server-git-4932f7dbf3ca279f2d2194ca2266428852a16e08.tar.gz
Fix `rabbitmqctl list_consumers`
As we are mapping over queues in search of their consumers, actual result for every queue could be zero or more consumers. We need to take that into account while printing. Closes #701
-rw-r--r--src/rabbit_control_main.erl27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/rabbit_control_main.erl b/src/rabbit_control_main.erl
index b805d21e48..ded52d2c00 100644
--- a/src/rabbit_control_main.erl
+++ b/src/rabbit_control_main.erl
@@ -753,15 +753,26 @@ default_if_empty(List, Default) when is_list(List) ->
true -> [list_to_atom(X) || X <- List]
end.
+display_info_message_row(IsEscaped, Result, InfoItemKeys) ->
+ display_row([format_info_item(
+ case proplists:lookup(X, Result) of
+ none when is_list(Result), length(Result) > 0 ->
+ exit({error, {bad_info_key, X}});
+ none -> Result;
+ {X, Value} -> Value
+ end, IsEscaped) || X <- InfoItemKeys]).
+
display_info_message(IsEscaped) ->
- fun(Result, InfoItemKeys) ->
- display_row([format_info_item(
- case proplists:lookup(X, Result) of
- none when is_list(Result), length(Result) > 0 ->
- exit({error, {bad_info_key, X}});
- none -> Result;
- {X, Value} -> Value
- end, IsEscaped) || X <- InfoItemKeys])
+ fun ([], _) ->
+ ok;
+ ([FirstResult|_] = List, InfoItemKeys) when is_list(FirstResult) ->
+ lists:foreach(fun(Result) ->
+ display_info_message_row(IsEscaped, Result, InfoItemKeys)
+ end,
+ List),
+ ok;
+ (Result, InfoItemKeys) ->
+ display_info_message_row(IsEscaped, Result, InfoItemKeys)
end.
display_info_list(Results, InfoItemKeys) when is_list(Results) ->