diff --git a/deps/rabbit/src/rabbit_amqp_management.erl b/deps/rabbit/src/rabbit_amqp_management.erl index ddc2550decbf..edd64030e471 100644 --- a/deps/rabbit/src/rabbit_amqp_management.erl +++ b/deps/rabbit/src/rabbit_amqp_management.erl @@ -98,22 +98,20 @@ handle_http_req(<<"PUT">>, ok = prohibit_default_exchange(XNameBin), XName = rabbit_misc:r(Vhost, exchange, XNameBin), ok = check_resource_access(XName, configure, User), - {StatCode, X} = case rabbit_exchange:lookup(XName) of - {ok, FoundX} -> - {<<"200">>, FoundX}; - {error, not_found} -> - ok = prohibit_cr_lf(XNameBin), - ok = prohibit_reserved_amq(XName), - X0 = rabbit_exchange:declare( - XName, XTypeAtom, Durable, AutoDelete, - Internal, XArgs, Username), - {<<"201">>, X0} - end, + X = case rabbit_exchange:lookup(XName) of + {ok, FoundX} -> + FoundX; + {error, not_found} -> + ok = prohibit_cr_lf(XNameBin), + ok = prohibit_reserved_amq(XName), + rabbit_exchange:declare( + XName, XTypeAtom, Durable, AutoDelete, + Internal, XArgs, Username) + end, try rabbit_exchange:assert_equivalence( X, XTypeAtom, Durable, AutoDelete, Internal, XArgs) of ok -> - %%TODO Include the exchange in the response payload - {StatCode, [], null} + {<<"204">>, [], null} catch exit:#amqp_error{name = precondition_failed, explanation = Expl} -> throw(<<"409">>, Expl, []) diff --git a/deps/rabbit/src/rabbit_db_exchange.erl b/deps/rabbit/src/rabbit_db_exchange.erl index 2cf2371cbc0c..97fccc2615b2 100644 --- a/deps/rabbit/src/rabbit_db_exchange.erl +++ b/deps/rabbit/src/rabbit_db_exchange.erl @@ -358,7 +358,7 @@ update_in_khepri_tx(Name, Fun) -> -spec create_or_get(Exchange) -> Ret when Exchange :: rabbit_types:exchange(), - Ret :: {new, Exchange} | {existing, Exchange} | {error, any()}. + Ret :: {new, Exchange} | {existing, Exchange}. %% @doc Writes an exchange record if it doesn't exist already or returns %% the existing one. %% diff --git a/deps/rabbit/src/rabbit_exchange.erl b/deps/rabbit/src/rabbit_exchange.erl index dbf35dbc11f6..3ecb87ba7eaf 100644 --- a/deps/rabbit/src/rabbit_exchange.erl +++ b/deps/rabbit/src/rabbit_exchange.erl @@ -94,7 +94,7 @@ serial(X) -> -spec declare (name(), type(), boolean(), boolean(), boolean(), rabbit_framing:amqp_table(), rabbit_types:username()) - -> rabbit_types:exchange() | {error, term()}. + -> rabbit_types:exchange(). declare(XName, Type, Durable, AutoDelete, Internal, Args, Username) -> X = rabbit_exchange_decorator:set( @@ -123,9 +123,7 @@ declare(XName, Type, Durable, AutoDelete, Internal, Args, Username) -> rabbit_event:notify(exchange_created, info(Exchange)), Exchange; {existing, Exchange} -> - Exchange; - Err -> - Err + Exchange end; _ -> rabbit_log:warning("ignoring exchange.declare for exchange ~tp, diff --git a/deps/rabbitmq_amqp_client/src/rabbitmq_amqp_client.erl b/deps/rabbitmq_amqp_client/src/rabbitmq_amqp_client.erl index c0863280dc10..fecd6d0b25cc 100644 --- a/deps/rabbitmq_amqp_client/src/rabbitmq_amqp_client.erl +++ b/deps/rabbitmq_amqp_client/src/rabbitmq_amqp_client.erl @@ -347,7 +347,7 @@ declare_exchange(LinkPair, ExchangeProperties) -> case request(LinkPair, Props, Body) of {ok, Resp} -> case amqp10_msg:properties(Resp) of - #{subject := <<"201">>} -> + #{subject := <<"204">>} -> #'v1_0.amqp_value'{content = null} = amqp10_msg:body(Resp), ok; _ ->