summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Lebedeff <alebedev@mirantis.com>2016-03-23 17:49:07 +0300
committerAlexey Lebedeff <alebedev@mirantis.com>2016-03-23 18:23:30 +0300
commit859a3a520764b394507df7dc35c6a29efb444f5c (patch)
tree5cb2437c580bd97def59c6b2e55603fb56bc5d1f
parentae548891fc8a6c8e8254e064d91e3b4e89eba8d6 (diff)
downloadrabbitmq-server-git-859a3a520764b394507df7dc35c6a29efb444f5c.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) ->