From 49b51db2311fb4b5c91d6c29556ff89e3cea4c55 Mon Sep 17 00:00:00 2001 From: JianBo He Date: Thu, 28 Apr 2022 22:27:44 +0800 Subject: [PATCH] fix(gw): fix deep_merge can't update the configuration correctly --- apps/emqx_gateway/src/emqx_gateway_conf.erl | 25 +++++++++------------ 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/apps/emqx_gateway/src/emqx_gateway_conf.erl b/apps/emqx_gateway/src/emqx_gateway_conf.erl index 7cc26906b..4628d856a 100644 --- a/apps/emqx_gateway/src/emqx_gateway_conf.erl +++ b/apps/emqx_gateway/src/emqx_gateway_conf.erl @@ -478,12 +478,9 @@ pre_config_update(_, {update_authn, GwName, Conf}, RawConf) -> of undefined -> badres_authn(not_found, GwName); - _ -> - {ok, - emqx_map_lib:deep_merge( - RawConf, - #{GwName => #{?AUTHN_BIN => Conf}} - )} + Authn -> + NAuthn = maps:merge(Authn, Conf), + {ok, emqx_map_lib:deep_put([GwName, ?AUTHN_BIN], RawConf, NAuthn)} end; pre_config_update(_, {update_authn, GwName, {LType, LName}, Conf}, RawConf) -> case @@ -502,17 +499,15 @@ pre_config_update(_, {update_authn, GwName, {LType, LName}, Conf}, RawConf) -> Auth -> NListener = maps:put( ?AUTHN_BIN, - emqx_map_lib:deep_merge(Auth, Conf), + maps:merge(Auth, Conf), Listener ), - NGateway = #{ - GwName => - #{ - <<"listeners">> => - #{LType => #{LName => NListener}} - } - }, - {ok, emqx_map_lib:deep_merge(RawConf, NGateway)} + {ok, + emqx_map_lib:deep_put( + [GwName, <<"listeners">>, LType, LName], + RawConf, + NListener + )} end end; pre_config_update(_, {remove_authn, GwName}, RawConf) ->