Просмотр исходного кода

fix(bridges): function clause when a non-ingress bridge coexists with an egress bridge

This was not caught by our tests because we always test bridge types
in isolation.  So, if the config only contains ingress-only bridges,
the `on_message_publish` hook is never installed.

In a real system, if there are bridges of mixed types in the config,
the hook might be installed, and `emqx_bridge:get_matched_bridge_id`
would crash when iterating over the ingress bridges.
Thales Macedo Garitezi 2 лет назад
Родитель
Сommit
3954b7bde2
1 измененных файлов с 3 добавлено и 1 удалено
  1. 3 1
      apps/emqx_bridge/src/emqx_bridge.erl

+ 3 - 1
apps/emqx_bridge/src/emqx_bridge.erl

@@ -411,7 +411,9 @@ get_matched_bridge_id(BType, Conf, Topic, BName, Acc) when ?EGRESS_DIR_BRIDGES(B
             do_get_matched_bridge_id(Topic, Filter, BType, BName, Acc)
     end;
 get_matched_bridge_id(mqtt, #{egress := #{local := #{topic := Filter}}}, Topic, BName, Acc) ->
-    do_get_matched_bridge_id(Topic, Filter, mqtt, BName, Acc).
+    do_get_matched_bridge_id(Topic, Filter, mqtt, BName, Acc);
+get_matched_bridge_id(_BType, _Conf, _Topic, _BName, Acc) ->
+    Acc.
 
 do_get_matched_bridge_id(Topic, Filter, BType, BName, Acc) ->
     case emqx_topic:match(Topic, Filter) of