summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2013-01-16 17:56:37 +0000
committerSimon MacMullen <simon@rabbitmq.com>2013-01-16 17:56:37 +0000
commit14853a854485a3f20096eb73f03d31046e6f445f (patch)
tree7d12f40540272e3e20c5fbf51983b31e9db6091d /src
parentb3431dbec544fe3196bf79bc931c134f9cff7b60 (diff)
parent755be5f05eb0c5c7339e29846edf37e78cab2ab0 (diff)
downloadrabbitmq-server-git-14853a854485a3f20096eb73f03d31046e6f445f.tar.gz
stable to default
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_policy.erl13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/rabbit_policy.erl b/src/rabbit_policy.erl
index 2c997f16bb..fa13c5ddd5 100644
--- a/src/rabbit_policy.erl
+++ b/src/rabbit_policy.erl
@@ -218,10 +218,13 @@ validation(_Name, Terms) when is_list(Terms) ->
rabbit_registry:lookup_all(policy_validator)),
[] = dups(Keys), %% ASSERTION
Validators = lists:zipwith(fun (M, K) -> {M, a2b(K)} end, Modules, Keys),
- {TermKeys, _} = lists:unzip(Terms),
- case dups(TermKeys) of
- [] -> validation0(Validators, Terms);
- Dup -> {error, "~p duplicate keys not allowed", [Dup]}
+ case is_proplist(Terms) of
+ true -> {TermKeys, _} = lists:unzip(Terms),
+ case dups(TermKeys) of
+ [] -> validation0(Validators, Terms);
+ Dup -> {error, "~p duplicate keys not allowed", [Dup]}
+ end;
+ false -> {error, "definition must be a dictionary: ~p", [Terms]}
end;
validation(_Name, Term) ->
{error, "parse error while reading policy: ~p", [Term]}.
@@ -249,3 +252,5 @@ validation0(Validators, Terms) ->
a2b(A) -> list_to_binary(atom_to_list(A)).
dups(L) -> L -- lists:usort(L).
+
+is_proplist(L) -> length(L) =:= length([I || I = {_, _} <- L]).