Fix thrift_processor so that exceptions thrown in async void functions don't get serialized
Test plan: Made testAsync() in test_server always crash with a badmatch 1 = 0,
and made sure that the badmatch was caught and logged but not
serialized back to the client
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@666416 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/alterl/src/thrift_processor.erl b/lib/alterl/src/thrift_processor.erl
index 2b435ac..aa2666e 100644
--- a/lib/alterl/src/thrift_processor.erl
+++ b/lib/alterl/src/thrift_processor.erl
@@ -52,11 +52,27 @@
% [Function, Params, Micro/1000.0]),
handle_success(State, Function, Result)
catch
- throw:Exception when is_tuple(Exception), size(Exception) > 0 ->
+ Type:Data ->
+ handle_function_catch(State, Function, Type, Data)
+ end.
+
+handle_function_catch(State = #state{service = Service},
+ Function, ErrType, ErrData) ->
+ IsAsync = Service:function_info(Function, reply_type) =:= async_void,
+
+ case {ErrType, ErrData} of
+ _ when IsAsync ->
+ error_logger:warning_msg(
+ "async void ~p threw error which must be ignored: ~p",
+ [Function, {ErrType, ErrData}]),
+ ok;
+
+ {throw, Exception} when is_tuple(Exception), size(Exception) > 0 ->
error_logger:warning_msg("~p threw exception: ~p~n", [Function, Exception]),
handle_exception(State, Function, Exception),
ok; % we still want to accept more requests from this client
- error:Error ->
+
+ {error, Error} ->
ok = handle_error(State, Function, Error)
end.