From: Jens Geyer Date: Wed, 16 Apr 2014 20:43:08 +0000 (+0200) Subject: THRIFT-2470 THttpHandler swallows exceptions from processor X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=057be5a9bd32e3571577edeab1aa0ea7c50087d6;p=common%2Fthrift.git THRIFT-2470 THttpHandler swallows exceptions from processor Client: C# Patch: Adam Conelly This closes #100 commit 6dcb1c3dc5d3259574863f0bc6af67b241b4653e Author: Adam Connelly Date: 2014-04-16T14:37:54Z THRIFT-2470: Stop THttpHandler from swallowing processor exceptions The problem with the way it works currently is that it makes it very difficult to figure out what's going on when I've got a handler running on a remote web server. If the handler just allows the exceptions to bubble up like normal, they get caught by our normal exception handling code and logged. I also added a new project for unit tests, and some tests for the changes I've made. --- diff --git a/lib/csharp/src/Transport/THttpHandler.cs b/lib/csharp/src/Transport/THttpHandler.cs index 0a10d796..884f1adb 100644 --- a/lib/csharp/src/Transport/THttpHandler.cs +++ b/lib/csharp/src/Transport/THttpHandler.cs @@ -63,30 +63,23 @@ namespace Thrift.Transport { TTransport transport = new TStreamTransport(input,output); - TProtocol inputProtocol = null; - TProtocol outputProtocol = null; - try { - inputProtocol = inputProtocolFactory.GetProtocol(transport); - outputProtocol = outputProtocolFactory.GetProtocol(transport); + var inputProtocol = inputProtocolFactory.GetProtocol(transport); + var outputProtocol = outputProtocolFactory.GetProtocol(transport); - while (processor.Process(inputProtocol, outputProtocol)) { } + while (processor.Process(inputProtocol, outputProtocol)) + { + } } catch (TTransportException) { // Client died, just move on } - catch (TApplicationException tx) - { - Console.Error.Write(tx); - } - catch (Exception x) + finally { - Console.Error.Write(x); + transport.Close(); } - - transport.Close(); } public bool IsReusable