Author: dreiss
Date: Tue Jun 10 17:57:42 2008
New Revision: 666416

URL: http://svn.apache.org/viewvc?rev=666416&view=rev
Log:
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

Modified:
    incubator/thrift/trunk/lib/alterl/src/thrift_processor.erl

Modified: incubator/thrift/trunk/lib/alterl/src/thrift_processor.erl
URL: 
http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/alterl/src/thrift_processor.erl?rev=666416&r1=666415&r2=666416&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/alterl/src/thrift_processor.erl (original)
+++ incubator/thrift/trunk/lib/alterl/src/thrift_processor.erl Tue Jun 10 
17:57:42 2008
@@ -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.
 


Reply via email to