Skip to content

Commit

Permalink
remove try-catch that was used for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
BBBSnowball committed Apr 1, 2018
1 parent 628e74e commit 4cb6f59
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions src/rabbit_mqtt_retained_msg_store_ets.erl
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,19 @@ insert(Topic, Msg, #store_state{table = T}) ->
ok.

lookup(Topic, #store_state{table = T}) ->
try
case re:run(Topic, "[+#]") of
nomatch -> ets:lookup(T, Topic);
_ ->
RegexTopic1 = re:replace(Topic, "[.()\\[\\]\\\\{}]", "\\\\\\0"),
RegexTopic2 = re:replace(RegexTopic1, "(^|/)[+]($|/)", "\\1[^/]+\\2"),
RegexTopic3 = re:replace(RegexTopic2, "(^|/)[#]($|/)", "\\1.+\\2"),
{ok,RegexTopic} = re:compile(["^", RegexTopic3, "$"]),
ets:foldl(fun (#retained_message{topic = ThisTopic} = Elem, Acc) ->
case re:run(ThisTopic, RegexTopic) of
nomatch -> Acc;
_ -> [Elem | Acc]
end
end, [], T)
end
catch
Class:Reason -> lager:error("~nError in lookup for Topic ~p:~s", [Topic, lager:pr_stacktrace(erlang:get_stacktrace(), {Class, Reason})])
case re:run(Topic, "[+#]") of
nomatch -> ets:lookup(T, Topic);
_ ->
RegexTopic1 = re:replace(Topic, "[.()\\[\\]\\\\{}]", "\\\\\\0"),
RegexTopic2 = re:replace(RegexTopic1, "(^|/)[+]($|/)", "\\1[^/]+\\2"),
RegexTopic3 = re:replace(RegexTopic2, "(^|/)[#]($|/)", "\\1.+\\2"),
{ok,RegexTopic} = re:compile(["^", RegexTopic3, "$"]),
ets:foldl(fun (#retained_message{topic = ThisTopic} = Elem, Acc) ->
case re:run(ThisTopic, RegexTopic) of
nomatch -> Acc;
_ -> [Elem | Acc]
end
end, [], T)
end.

delete(Topic, #store_state{table = T}) ->
Expand Down

0 comments on commit 4cb6f59

Please sign in to comment.