summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlvaro Videla <alvaro@rabbitmq.com>2014-01-08 00:08:20 +0100
committerAlvaro Videla <alvaro@rabbitmq.com>2014-01-08 00:08:20 +0100
commit12a1bdca454231ad355c63c9773c099ed5909eaf (patch)
treedd220e4d7d5bb1148187006b814b7215fb2954a3 /src
parent59193ac193fb72b6d1a22d2f943f15de35de9ab9 (diff)
downloadrabbitmq-server-git-12a1bdca454231ad355c63c9773c099ed5909eaf.tar.gz
checks the interceptor returns the right method
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_channel_interceptor.erl26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/rabbit_channel_interceptor.erl b/src/rabbit_channel_interceptor.erl
index 00ed4f0359..5d1665e028 100644
--- a/src/rabbit_channel_interceptor.erl
+++ b/src/rabbit_channel_interceptor.erl
@@ -61,19 +61,31 @@ intercept_method(M, []) ->
intercept_method(M, [I]) ->
case I:intercept(M) of
{ok, M2} ->
- M2;
+ case validate_method(M, M2) of
+ true ->
+ M2;
+ _ ->
+ internal_error("Interceptor: ~p expected "
+ "to return method: ~p but returned: ~p",
+ [I, rabbit_misc:method_record_type(M),
+ rabbit_misc:method_record_type(M2)])
+ end;
{error, Reason} ->
- rabbit_misc:protocol_error(internal_error,
- "Interceptor: ~p failed with reason: ~p",
- [I, Reason])
+ internal_error("Interceptor: ~p failed with reason: ~p",
+ [I, Reason])
end;
intercept_method(M, Is) ->
- rabbit_misc:protocol_error(internal_error,
- "More than one interceptor for method: ~p -- ~p",
- [rabbit_misc:method_record_type(M), Is]).
+ internal_error("More than one interceptor for method: ~p -- ~p",
+ [rabbit_misc:method_record_type(M), Is]).
%% select the interceptors that apply to intercept_method().
select(Method) ->
[M || {_, M} <- rabbit_registry:lookup_all(channel_interceptor),
code:which(M) =/= non_existing,
M:applies_to(Method)].
+
+validate_method(M, M2) ->
+ rabbit_misc:method_record_type(M) =:= rabbit_misc:method_record_type(M2).
+
+internal_error(Format, Args) ->
+ rabbit_misc:protocol_error(internal_error, Format, Args). \ No newline at end of file