summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Radestock <matthias@rabbitmq.com>2013-08-05 15:22:34 +0100
committerMatthias Radestock <matthias@rabbitmq.com>2013-08-05 15:22:34 +0100
commiteb4c410d607d7e9cfa6c102038ef9c6f48ad8725 (patch)
tree9b8673f15a3f51660ac7e9670d26c3e05e67c675
parent0a3633c7e311e6783454f92bda72a73f086b4f77 (diff)
parent06624451996a382461fd41a9f6cfadc919129573 (diff)
downloadrabbitmq-server-eb4c410d607d7e9cfa6c102038ef9c6f48ad8725.tar.gz
merge bug25686 into stable
-rw-r--r--src/rabbit_amqqueue.erl4
-rw-r--r--src/rabbit_channel.erl21
-rw-r--r--src/rabbit_misc.erl11
3 files changed, 26 insertions, 10 deletions
diff --git a/src/rabbit_amqqueue.erl b/src/rabbit_amqqueue.erl
index a6181a95..a1efaf65 100644
--- a/src/rabbit_amqqueue.erl
+++ b/src/rabbit_amqqueue.erl
@@ -412,13 +412,9 @@ check_declare_arguments(QueueName, Args) ->
args() ->
[{<<"x-expires">>, fun check_expires_arg/2},
{<<"x-message-ttl">>, fun check_message_ttl_arg/2},
- {<<"x-dead-letter-exchange">>, fun check_string_arg/2},
{<<"x-dead-letter-routing-key">>, fun check_dlxrk_arg/2},
{<<"x-max-length">>, fun check_max_length_arg/2}].
-check_string_arg({longstr, _}, _Args) -> ok;
-check_string_arg({Type, _}, _Args) -> {error, {unacceptable_type, Type}}.
-
check_int_arg({Type, _}, _) ->
case lists:member(Type, ?INTEGER_ARG_TYPES) of
true -> ok;
diff --git a/src/rabbit_channel.erl b/src/rabbit_channel.erl
index a8e9432c..d6c1e8c0 100644
--- a/src/rabbit_channel.erl
+++ b/src/rabbit_channel.erl
@@ -894,9 +894,13 @@ handle_method(#'exchange.declare'{exchange = ExchangeNameBin,
{ok, FoundX} -> FoundX;
{error, not_found} ->
check_name('exchange', ExchangeNameBin),
- case rabbit_misc:r_arg(VHostPath, exchange, Args,
- <<"alternate-exchange">>) of
+ AeKey = <<"alternate-exchange">>,
+ case rabbit_misc:r_arg(VHostPath, exchange, Args, AeKey) of
undefined -> ok;
+ {error, {invalid_type, Type}} ->
+ precondition_failed(
+ "invalid type '~s' for arg '~s' in ~s",
+ [Type, AeKey, rabbit_misc:rs(ExchangeName)]);
AName -> check_read_permitted(ExchangeName, State),
check_write_permitted(AName, State),
ok
@@ -986,6 +990,19 @@ handle_method(#'queue.declare'{queue = QueueNameBin,
return_queue_declare_ok(QueueName, NoWait, MessageCount,
ConsumerCount, State);
{error, not_found} ->
+ DlxKey = <<"x-dead-letter-exchange">>,
+ case rabbit_misc:r_arg(VHostPath, exchange, Args, DlxKey) of
+ undefined ->
+ ok;
+ {error, {invalid_type, Type}} ->
+ precondition_failed(
+ "invalid type '~s' for arg '~s' in ~s",
+ [Type, DlxKey, rabbit_misc:rs(QueueName)]);
+ DLX ->
+ check_read_permitted(QueueName, State),
+ check_write_permitted(DLX, State),
+ ok
+ end,
case rabbit_amqqueue:declare(QueueName, Durable, AutoDelete,
Args, Owner) of
{new, #amqqueue{pid = QPid}} ->
diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl
index 84b15aa9..e9fe8134 100644
--- a/src/rabbit_misc.erl
+++ b/src/rabbit_misc.erl
@@ -142,9 +142,11 @@
when is_subtype(K, atom())).
-spec(r_arg/4 ::
(rabbit_types:vhost() | rabbit_types:r(atom()), K,
- rabbit_framing:amqp_table(), binary())
- -> undefined | rabbit_types:r(K)
- when is_subtype(K, atom())).
+ rabbit_framing:amqp_table(), binary()) ->
+ undefined |
+ rabbit_types:error(
+ {invalid_type, rabbit_framing:amqp_field_type()}) |
+ rabbit_types:r(K) when is_subtype(K, atom())).
-spec(rs/1 :: (rabbit_types:r(atom())) -> string()).
-spec(enable_cover/0 :: () -> ok_or_error()).
-spec(start_cover/1 :: ([{string(), string()} | string()]) -> 'ok').
@@ -370,7 +372,8 @@ r_arg(#resource{virtual_host = VHostPath}, Kind, Table, Key) ->
r_arg(VHostPath, Kind, Table, Key) ->
case table_lookup(Table, Key) of
{longstr, NameBin} -> r(VHostPath, Kind, NameBin);
- undefined -> undefined
+ undefined -> undefined;
+ {Type, _} -> {error, {invalid_type, Type}}
end.
rs(#resource{virtual_host = VHostPath, kind = Kind, name = Name}) ->