From 5541d658643bbd2c2e1c62ee489e25a7706b9d62 Mon Sep 17 00:00:00 2001 From: David Reiss Date: Wed, 11 Jun 2008 00:57:42 +0000 Subject: [PATCH] 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 --- lib/alterl/src/thrift_processor.erl | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/alterl/src/thrift_processor.erl b/lib/alterl/src/thrift_processor.erl index 2b435acb..aa2666e4 100644 --- a/lib/alterl/src/thrift_processor.erl +++ b/lib/alterl/src/thrift_processor.erl @@ -52,11 +52,27 @@ handle_function(State = #state{in_protocol = IProto, % [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. -- 2.17.1