summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Klishin <michael@novemberain.com>2015-07-29 11:00:17 +0300
committerMichael Klishin <michael@novemberain.com>2015-07-29 11:00:17 +0300
commitac5373f34ec1dac6ad338d14580d28c7c2d4132e (patch)
tree9e8c9cc04e76db0e2837d2bb853f9a7b7ae40b33
parent0c9509eeb85ca3e0091fd617e3d6365258a43c04 (diff)
parent32d0d87699e1c5cf6585f3cddda6aedb468be69d (diff)
downloadrabbitmq-server-git-ac5373f34ec1dac6ad338d14580d28c7c2d4132e.tar.gz
Merge pull request #236 from legoscia/remove_nonexistent_bindings
Don't crash when removing non-existent bindings
-rw-r--r--src/rabbit_exchange_type_topic.erl19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/rabbit_exchange_type_topic.erl b/src/rabbit_exchange_type_topic.erl
index afbfc652b1..53fb762539 100644
--- a/src/rabbit_exchange_type_topic.erl
+++ b/src/rabbit_exchange_type_topic.erl
@@ -76,11 +76,14 @@ remove_bindings(transaction, _X, Bs) ->
rabbit_topic_trie_edge,
rabbit_topic_trie_binding]]
end,
- [begin
- Path = [{FinalNode, _} | _] =
- follow_down_get_path(X, split_topic_key(K)),
- trie_remove_binding(X, FinalNode, D, Args),
- remove_path_if_empty(X, Path)
+ [case follow_down_get_path(X, split_topic_key(K)) of
+ {ok, Path = [{FinalNode, _} | _]} ->
+ trie_remove_binding(X, FinalNode, D, Args),
+ remove_path_if_empty(X, Path);
+ {error, _Node, _RestW} ->
+ %% We're trying to remove a binding that no longer exists.
+ %% That's unexpected, but shouldn't be a problem.
+ ok
end || #binding{source = X, key = K, destination = D, args = Args} <- Bs],
ok;
remove_bindings(none, _X, _Bs) ->
@@ -137,10 +140,8 @@ follow_down_last_node(X, Words) ->
follow_down(X, fun (_, Node, _) -> Node end, root, Words).
follow_down_get_path(X, Words) ->
- {ok, Path} =
- follow_down(X, fun (W, Node, PathAcc) -> [{Node, W} | PathAcc] end,
- [{root, none}], Words),
- Path.
+ follow_down(X, fun (W, Node, PathAcc) -> [{Node, W} | PathAcc] end,
+ [{root, none}], Words).
follow_down(X, AccFun, Acc0, Words) ->
follow_down(X, root, AccFun, Acc0, Words).