summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/rabbit_control_main.erl4
-rw-r--r--src/rabbit_policy.erl7
2 files changed, 5 insertions, 6 deletions
diff --git a/src/rabbit_control_main.erl b/src/rabbit_control_main.erl
index 1619f25494..babaf4fd4e 100644
--- a/src/rabbit_control_main.erl
+++ b/src/rabbit_control_main.erl
@@ -537,7 +537,7 @@ action(set_policy, Node, [Key, Pattern, Defn], Opts, Inform) ->
Inform(Msg, [Key, Pattern, Defn, PriorityArg]),
Res = rpc_call(
Node, rabbit_policy, parse_set,
- [VHostArg, list_to_binary(Key), Pattern, Defn, PriorityArg, ApplyToArg]),
+ [VHostArg, list_to_binary(Key), list_to_binary(Pattern), list_to_binary(Defn), list_to_binary(PriorityArg), ApplyToArg]),
case Res of
{error, Format, Args} when is_list(Format) andalso is_list(Args) ->
{error_string, rabbit_misc:format(Format, Args)};
@@ -558,7 +558,7 @@ action(set_operator_policy, Node, [Key, Pattern, Defn], Opts, Inform) ->
Inform(Msg, [Key, Pattern, Defn, PriorityArg]),
Res = rpc_call(
Node, rabbit_policy, parse_set_op,
- [VHostArg, list_to_binary(Key), Pattern, Defn, PriorityArg, ApplyToArg]),
+ [VHostArg, list_to_binary(Key), list_to_binary(Pattern), list_to_binary(Defn), list_to_binary(PriorityArg), ApplyToArg]),
case Res of
{error, Format, Args} when is_list(Format) andalso is_list(Args) ->
{error_string, rabbit_misc:format(Format, Args)};
diff --git a/src/rabbit_policy.erl b/src/rabbit_policy.erl
index cfbf116cbd..437842b8dd 100644
--- a/src/rabbit_policy.erl
+++ b/src/rabbit_policy.erl
@@ -205,18 +205,17 @@ parse_set(VHost, Name, Pattern, Definition, Priority, ApplyTo) ->
parse_set(<<"policy">>, VHost, Name, Pattern, Definition, Priority, ApplyTo).
parse_set(Type, VHost, Name, Pattern, Definition, Priority, ApplyTo) ->
- try list_to_integer(Priority) of
+ try rabbit_data_coercion:to_integer(Priority) of
Num -> parse_set0(Type, VHost, Name, Pattern, Definition, Num, ApplyTo)
catch
error:badarg -> {error, "~p priority must be a number", [Priority]}
end.
parse_set0(Type, VHost, Name, Pattern, Defn, Priority, ApplyTo) ->
- Definition = rabbit_data_coercion:to_binary(Defn),
- case rabbit_json:try_decode(Definition) of
+ case rabbit_json:try_decode(Defn) of
{ok, Term} ->
set0(Type, VHost, Name,
- [{<<"pattern">>, list_to_binary(Pattern)},
+ [{<<"pattern">>, Pattern},
{<<"definition">>, maps:to_list(Term)},
{<<"priority">>, Priority},
{<<"apply-to">>, ApplyTo}]);