diff --git a/deps/rabbit/src/rabbit.erl b/deps/rabbit/src/rabbit.erl index 67d49c188741..87580bc2e387 100644 --- a/deps/rabbit/src/rabbit.erl +++ b/deps/rabbit/src/rabbit.erl @@ -1751,10 +1751,26 @@ persist_static_configuration() -> [classic_queue_index_v2_segment_entry_count, classic_queue_store_v2_max_cache_size, classic_queue_store_v2_check_crc32, - incoming_message_interceptors, - credit_flow_default_credit + incoming_message_interceptors ]), + %% Disallow the following two cases: + %% 1. Negative values + %% 2. MoreCreditAfter greater than InitialCredit + CreditFlowDefaultCredit = case application:get_env(?MODULE, credit_flow_default_credit) of + {ok, {InitialCredit, MoreCreditAfter}} + when is_integer(InitialCredit) andalso + is_integer(MoreCreditAfter) andalso + InitialCredit > 0 andalso + MoreCreditAfter > 0 andalso + MoreCreditAfter < InitialCredit -> + {InitialCredit, MoreCreditAfter}; + Other -> + rabbit_log:error("Refusing to boot due to an invalid value of 'rabbit.credit_flow_default_credit'"), + throw({error, {invalid_credit_flow_default_credit_value, Other}}) + end, + ok = persistent_term:put(credit_flow_default_credit, CreditFlowDefaultCredit), + %% Disallow 0 as it means unlimited: %% "If this field is zero or unset, there is no maximum %% size imposed by the link endpoint." [AMQP 1.0 ยง2.7.3]